From: "Bernatowicz, Marcin" <marcin.bernatowicz@linux.intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>,
igt-dev@lists.freedesktop.org
Cc: adam.miszczak@linux.intel.com, jakub1.kolakowski@intel.com,
lukasz.laguna@intel.com
Subject: Re: [PATCH i-g-t 2/5] lib/xe/xe_sriov_provisioning: Add sched priority mask to string helper
Date: Mon, 17 Nov 2025 12:00:12 +0100 [thread overview]
Message-ID: <1a594c0a-d921-42bd-a4cd-21d7f99b1806@linux.intel.com> (raw)
In-Reply-To: <7ae62677-eb16-4e8f-b55a-8c1356697a3d@intel.com>
On 11/14/2025 9:15 PM, Michal Wajdeczko wrote:
>
> On 11/14/2025 8:07 PM, Marcin Bernatowicz wrote:
>> Introduce xe_sriov_sched_priority_mask_to_string() to format a
>> scheduling priority bitmask as a space-separated list of priority names.
>>
>> 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 | 54 ++++++++++++++++++++++++++++++++++
>> lib/xe/xe_sriov_provisioning.h | 11 +++++++
>> 2 files changed, 65 insertions(+)
>>
>> diff --git a/lib/xe/xe_sriov_provisioning.c b/lib/xe/xe_sriov_provisioning.c
>> index 532335abe..da0df4d31 100644
>> --- a/lib/xe/xe_sriov_provisioning.c
>> +++ b/lib/xe/xe_sriov_provisioning.c
>> @@ -693,6 +693,60 @@ int xe_sriov_sched_priority_from_string(const char *s,
>> return -EINVAL;
>> }
>>
>> +_Static_assert(BIT(XE_SRIOV_SCHED_PRIORITY_LOW) == XE_SRIOV_SCHED_PRIORITY_MASK_LOW,
>> + "LOW mask bit must match enum order");
>> +_Static_assert(BIT(XE_SRIOV_SCHED_PRIORITY_NORMAL) == XE_SRIOV_SCHED_PRIORITY_MASK_NORMAL,
>> + "NORMAL mask bit must match enum order");
>> +_Static_assert(BIT(XE_SRIOV_SCHED_PRIORITY_HIGH) == XE_SRIOV_SCHED_PRIORITY_MASK_HIGH,
>> + "HIGH mask bit must match enum order");
> see below
>
>> +
>> +/**
>> + * xe_sriov_sched_priority_mask_to_string - Format priority mask as text
>> + * @mask: Priority bitmask.
>> + * @sel: Optional selected priority (NULL for none).
>> + * @buf: Output buffer.
>> + * @buf_sz: Size of @buf.
>> + *
>> + * Converts @mask to a space-separated string of priority names. If @sel is
>> + * non-NULL and present in @mask, that priority is wrapped in brackets, e.g.
>> + * "low [normal] high". Writes "none" if the mask is empty.
>> + *
>> + * Returns: @buf.
>> + */
>> +const char *xe_sriov_sched_priority_mask_to_string(unsigned int mask,
>> + const enum xe_sriov_sched_priority *sel,
> this shouldn't be "SR-IOV priority" only function, as such pattern is planned
> to be used also for other attributes
>
> you may just pass array of strings and index to the one you want to highlight
Ok, I'll add a generic helper to igt_sysfs:
const char *igt_sysfs_format_mask(char *buf, size_t buf_sz,
const char * const *names,
unsigned int mask,
int selected_idx);
and keep xe_sriov_sched_priority_mask_to_string() as a thin wrapper
passing the SR-IOV priority names and the selected enum.
>> + char *buf, size_t buf_sz)
>> +{
>> + size_t n = buf_sz;
>> + bool first = true;
>> + char *p = buf;
>> +
>> + igt_assert(buf && buf_sz);
>> +
>> + for (enum xe_sriov_sched_priority prio = XE_SRIOV_SCHED_PRIORITY_LOW;
>> + prio <= XE_SRIOV_SCHED_PRIORITY_HIGH; prio++) {
>> + const char *name = xe_sriov_sched_priority_to_string(prio);
>> + unsigned int bit = BIT(prio);
>> +
>> + if (mask & bit) {
>> + bool highlight = sel && (*sel == prio);
>> +
>> + p += snprintf(p, n, "%s%s%s%s",
>> + first ? "" : " ",
>> + highlight ? "[" : "",
>> + name ?: "?",
>> + highlight ? "]" : "");
>> + n = buf_sz - (p - buf);
>> + first = false;
>> + }
>> + }
>> +
>> + if (first)
>> + snprintf(buf, buf_sz, "none");
> if there is nothing then why not just return an empty string ?
I'll drop the "none" literal and return an empty string.
>> +
>> + return buf;
>> +}
>> +
>> /**
>> * __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 65f0597fe..9305eceec 100644
>> --- a/lib/xe/xe_sriov_provisioning.h
>> +++ b/lib/xe/xe_sriov_provisioning.h
>> @@ -75,6 +75,14 @@ enum xe_sriov_sched_priority {
>> XE_SRIOV_SCHED_PRIORITY_HIGH
>> };
>>
>> +#define XE_SRIOV_SCHED_PRIORITY_MASK_LOW (1u << XE_SRIOV_SCHED_PRIORITY_LOW)
>> +#define XE_SRIOV_SCHED_PRIORITY_MASK_NORMAL (1u << XE_SRIOV_SCHED_PRIORITY_NORMAL)
>> +#define XE_SRIOV_SCHED_PRIORITY_MASK_HIGH (1u << XE_SRIOV_SCHED_PRIORITY_HIGH)
> can't you use BIT() here?
>
> then above _Static_assert() could be dropped
Ok
>> +#define XE_SRIOV_SCHED_PRIORITY_MASK_ALL \
>> + (XE_SRIOV_SCHED_PRIORITY_MASK_LOW | \
>> + XE_SRIOV_SCHED_PRIORITY_MASK_NORMAL | \
>> + XE_SRIOV_SCHED_PRIORITY_MASK_HIGH)
>> +
>> /**
>> * struct xe_sriov_provisioned_range - Provisioned range for a Virtual Function (VF)
>> * @vf_id: The ID of the VF
>> @@ -143,6 +151,9 @@ int xe_sriov_sched_priority_from_string(const char *s, enum xe_sriov_sched_prior
>> int __xe_sriov_get_sched_priority(int pf, unsigned int vf_num,
>> unsigned int gt_num,
>> enum xe_sriov_sched_priority *value);
>> +const char *xe_sriov_sched_priority_mask_to_string(unsigned int mask,
>> + const enum xe_sriov_sched_priority *sel,
>> + char *buf, size_t buf_sz);
>> enum xe_sriov_sched_priority xe_sriov_get_sched_priority(int pf, unsigned int vf_num,
>> unsigned int gt_num);
>> int __xe_sriov_set_sched_priority(int pf, unsigned int vf_num, unsigned int gt_num,
next prev parent reply other threads:[~2025-11-17 11:00 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 ` [PATCH i-g-t 1/5] lib/xe/xe_sriov_provisioning: Add string conversion helpers for scheduling priority Marcin Bernatowicz
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 [this message]
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=1a594c0a-d921-42bd-a4cd-21d7f99b1806@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).