From: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: kamil.konieczny@linux.intel.com, adam.miszczak@linux.intel.com,
jakub1.kolakowski@intel.com, lukasz.laguna@intel.com,
michal.wajdeczko@intel.com, michal.winiarski@intel.com,
narasimha.c.v@intel.com, piotr.piorkowski@intel.com,
satyanarayana.k.v.p@intel.com, tomasz.lis@intel.com,
Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
Subject: [PATCH i-g-t 4/4] lib/xe/xe_sriov_provisioning: Add accessors for quota/spare attributes
Date: Wed, 27 Nov 2024 21:03:02 +0100 [thread overview]
Message-ID: <20241127200302.1376594-5-marcin.bernatowicz@linux.intel.com> (raw)
In-Reply-To: <20241127200302.1376594-1-marcin.bernatowicz@linux.intel.com>
Introduce functions to get and set SR-IOV provisioning quota and spare
attributes. These functions provide access to shared resource attributes
such as GGTT, LMEM, contexts, and doorbells for both PF and VF contexts.
Add returning and asserting variants to allow flexible error handling
based on usage scenarios.
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: Michał Wajdeczko <michal.wajdeczko@intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
Cc: Narasimha C V <narasimha.c.v@intel.com>
Cc: Piotr Piórkowski <piotr.piorkowski@intel.com>
Cc: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
Cc: Tomasz Lis <tomasz.lis@intel.com>
---
lib/xe/xe_sriov_provisioning.c | 123 +++++++++++++++++++++++++++++++++
lib/xe/xe_sriov_provisioning.h | 14 ++++
2 files changed, 137 insertions(+)
diff --git a/lib/xe/xe_sriov_provisioning.c b/lib/xe/xe_sriov_provisioning.c
index 0c5cd01fd..ce06c00de 100644
--- a/lib/xe/xe_sriov_provisioning.c
+++ b/lib/xe/xe_sriov_provisioning.c
@@ -561,3 +561,126 @@ void xe_sriov_require_default_scheduling_attributes(int pf)
}
}
}
+
+/**
+ * xe_sriov_shared_res_attr_name - Retrieve the attribute name for a shared resource
+ * @res: Shared resource type (see enum xe_sriov_shared_res)
+ * @vf_num: VF number (1-based) or 0 for PF
+ *
+ * Returns the attribute name corresponding to the specified
+ * shared resource type and VF number. For VF (vf_num > 0), the "quota"
+ * attribute name is returned (e.g., "contexts_quota"). For PF (vf_num == 0),
+ * the "spare" attribute name is returned (e.g., "contexts_spare").
+ *
+ * Return:
+ * The attribute name as a string if the resource type is valid.
+ * NULL if the resource type is invalid.
+ */
+const char *xe_sriov_shared_res_attr_name(enum xe_sriov_shared_res res,
+ unsigned int vf_num)
+{
+ switch (res) {
+ case XE_SRIOV_SHARED_RES_CONTEXTS:
+ return vf_num ? "contexts_quota" : "contexts_spare";
+ case XE_SRIOV_SHARED_RES_DOORBELLS:
+ return vf_num ? "doorbells_quota" : "doorbells_spare";
+ case XE_SRIOV_SHARED_RES_GGTT:
+ return vf_num ? "ggtt_quota" : "ggtt_spare";
+ case XE_SRIOV_SHARED_RES_LMEM:
+ return vf_num ? "lmem_quota" : "lmem_spare";
+ }
+
+ return NULL;
+}
+
+/**
+ * __xe_sriov_pf_get_shared_res_attr - Read shared resource attribute
+ * @pf: PF device file descriptor
+ * @res: Shared resource type (see enum xe_sriov_shared_res)
+ * @vf_num: VF number (1-based) or 0 for PF
+ * @gt_num: GT number
+ * @value: Pointer to store the read attribute value
+ *
+ * Reads the specified shared resource attribute for the given PF device @pf,
+ * VF number @vf_num, and GT @gt_num. The attribute depends on @vf_num:
+ * - For VF (vf_num > 0), reads the "quota" attribute.
+ * - For PF (vf_num == 0), reads the "spare" attribute.
+ *
+ *
+ * Return: 0 on success, negative error code on failure.
+ */
+int __xe_sriov_pf_get_shared_res_attr(int pf, enum xe_sriov_shared_res res,
+ unsigned int vf_num, unsigned int gt_num,
+ uint64_t *value)
+{
+ return __xe_sriov_pf_debugfs_get_u64(pf, vf_num, gt_num,
+ xe_sriov_shared_res_attr_name(res, vf_num),
+ value);
+}
+
+/**
+ * xe_sriov_pf_get_shared_res_attr - Read shared resource attribute
+ * @pf: PF device file descriptor
+ * @res: Shared resource type (see enum xe_sriov_shared_res)
+ * @vf_num: VF number (1-based) or 0 for PF
+ * @gt_num: GT number
+ *
+ * A throwing version of __xe_sriov_pf_get_shared_res_attr().
+ * Instead of returning an error code, it returns the quota value and asserts
+ * in case of an error.
+ *
+ * Return: The value for the given shared resource attribute.
+ * Asserts in case of failure.
+ */
+uint64_t xe_sriov_pf_get_shared_res_attr(int pf, enum xe_sriov_shared_res res,
+ unsigned int vf_num,
+ unsigned int gt_num)
+{
+ uint64_t value;
+
+ igt_fail_on(__xe_sriov_pf_get_shared_res_attr(pf, res, vf_num, gt_num, &value));
+
+ return value;
+}
+
+/**
+ * __xe_sriov_pf_set_shared_res_attr - Set a shared resource attribute
+ * @pf: PF device file descriptor
+ * @res: Shared resource type (see enum xe_sriov_shared_res)
+ * @vf_num: VF number (1-based) or 0 for PF
+ * @gt_num: GT number
+ * @value: Value to set for the shared resource attribute
+ *
+ * Sets the specified shared resource attribute for the given PF device @pf,
+ * VF number @vf_num, and GT @gt_num. The attribute depends on @vf_num:
+ * - For VF (vf_num > 0), reads the "quota" attribute.
+ * - For PF (vf_num == 0), reads the "spare" attribute.
+ *
+ * Return: 0 on success, negative error code on failure.
+ */
+int __xe_sriov_pf_set_shared_res_attr(int pf, enum xe_sriov_shared_res res,
+ unsigned int vf_num, unsigned int gt_num,
+ uint64_t value)
+{
+ return __xe_sriov_pf_debugfs_set_u64(pf, vf_num, gt_num,
+ xe_sriov_shared_res_attr_name(res, vf_num),
+ value);
+}
+
+/**
+ * xe_sriov_pf_set_shared_res_attr - Set the shared resource attribute value
+ * @pf: PF device file descriptor
+ * @res: Shared resource type (see enum xe_sriov_shared_res)
+ * @vf_num: VF number (1-based) or 0 for PF
+ * @gt_num: GT number
+ * @value: Value to set
+ *
+ * A throwing version of __xe_sriov_pf_set_shared_res_attr().
+ * Instead of returning an error code, it asserts in case of an error.
+ */
+void xe_sriov_pf_set_shared_res_attr(int pf, enum xe_sriov_shared_res res,
+ unsigned int vf_num, unsigned int gt_num,
+ uint64_t value)
+{
+ igt_fail_on(__xe_sriov_pf_set_shared_res_attr(pf, res, vf_num, gt_num, value));
+}
diff --git a/lib/xe/xe_sriov_provisioning.h b/lib/xe/xe_sriov_provisioning.h
index 4ddf3149f..30e769019 100644
--- a/lib/xe/xe_sriov_provisioning.h
+++ b/lib/xe/xe_sriov_provisioning.h
@@ -100,5 +100,19 @@ int __xe_sriov_set_sched_priority(int pf, unsigned int vf_num, unsigned int gt_n
void xe_sriov_set_sched_priority(int pf, unsigned int vf_num, unsigned int gt_num,
enum xe_sriov_sched_priority value);
void xe_sriov_require_default_scheduling_attributes(int pf);
+const char *xe_sriov_shared_res_attr_name(enum xe_sriov_shared_res res,
+ unsigned int vf_num);
+int __xe_sriov_pf_get_shared_res_attr(int pf, enum xe_sriov_shared_res res,
+ unsigned int vf_num, unsigned int gt_num,
+ uint64_t *value);
+uint64_t xe_sriov_pf_get_shared_res_attr(int pf, enum xe_sriov_shared_res res,
+ unsigned int vf_num,
+ unsigned int gt_num);
+int __xe_sriov_pf_set_shared_res_attr(int pf, enum xe_sriov_shared_res res,
+ unsigned int vf_num, unsigned int gt_num,
+ uint64_t value);
+void xe_sriov_pf_set_shared_res_attr(int pf, enum xe_sriov_shared_res res,
+ unsigned int vf_num, unsigned int gt_num,
+ uint64_t value);
#endif /* __XE_SRIOV_PROVISIONING_H__ */
--
2.31.1
next prev parent reply other threads:[~2024-11-27 20:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-27 20:02 [PATCH i-g-t 0/4] Subject: [PATCH i-g-t 0/4] lib/xe: Add SR-IOV debugfs and provisioning helpers Marcin Bernatowicz
2024-11-27 20:02 ` [PATCH i-g-t 1/4] lib/xe/xe_sriov_debugfs: Add debugfs get/set functions for u32, u64, bool Marcin Bernatowicz
2024-12-02 13:03 ` Laguna, Lukasz
2024-12-05 15:36 ` Bernatowicz, Marcin
2024-11-27 20:03 ` [PATCH i-g-t 2/4] lib/xe/xe_sriov_provisioning: Add scheduling attributes accessors Marcin Bernatowicz
2024-11-27 20:03 ` [PATCH i-g-t 3/4] lib/xe/xe_sriov_provisioning: Add helper to check default scheduling attributes Marcin Bernatowicz
2024-11-27 20:03 ` Marcin Bernatowicz [this message]
2024-12-02 13:09 ` [PATCH i-g-t 4/4] lib/xe/xe_sriov_provisioning: Add accessors for quota/spare attributes Laguna, Lukasz
2024-11-27 20:33 ` ✓ Xe.CI.BAT: success for Subject: [PATCH i-g-t 0/4] lib/xe: Add SR-IOV debugfs and provisioning helpers Patchwork
2024-11-27 20:45 ` ✗ i915.CI.BAT: failure " Patchwork
2024-11-27 21:28 ` ✗ Xe.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=20241127200302.1376594-5-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=kamil.konieczny@linux.intel.com \
--cc=lukasz.laguna@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=michal.winiarski@intel.com \
--cc=narasimha.c.v@intel.com \
--cc=piotr.piorkowski@intel.com \
--cc=satyanarayana.k.v.p@intel.com \
--cc=tomasz.lis@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