From: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Marcin Bernatowicz" <marcin.bernatowicz@linux.intel.com>,
"Lukasz Laguna" <lukasz.laguna@intel.com>,
"Adam Miszczak" <adam.miszczak@linux.intel.com>,
"Jakub Kolakowski" <jakub1.kolakowski@intel.com>,
"Michał Wajdeczko" <michal.wajdeczko@intel.com>,
"Michał Winiarski" <michal.winiarski@intel.com>,
"Narasimha C V" <narasimha.c.v@intel.com>,
"Piotr Piórkowski" <piotr.piorkowski@intel.com>,
"Satyanarayana K V P" <satyanarayana.k.v.p@intel.com>,
"Tomasz Lis" <tomasz.lis@intel.com>
Subject: [PATCH v2 i-g-t 1/7] lib/xe/xe_sriov_debugfs: Add debugfs get/set functions for u32, u64, bool
Date: Tue, 14 Jan 2025 16:08:42 +0100 [thread overview]
Message-ID: <20250114150848.332708-2-marcin.bernatowicz@linux.intel.com> (raw)
In-Reply-To: <20250114150848.332708-1-marcin.bernatowicz@linux.intel.com>
Add helper functions to get and set SR-IOV debugfs attributes for u32,
u64, and boolean types.
Functions added:
- __xe_sriov_pf_debugfs_get_u32
- __xe_sriov_pf_debugfs_set_u32
- __xe_sriov_pf_debugfs_get_u64
- __xe_sriov_pf_debugfs_set_u64
- __xe_sriov_pf_debugfs_get_boolean
- __xe_sriov_pf_debugfs_set_boolean
v2: Updated DEFINE_XE_SRIOV_PF_DEBUGFS_FUNC macro comment (Lukasz)
Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
Reviewed-by: Lukasz Laguna <lukasz.laguna@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_debugfs.c | 151 ++++++++++++++++++++++++++++++++++++++
lib/xe/xe_sriov_debugfs.h | 18 +++++
2 files changed, 169 insertions(+)
diff --git a/lib/xe/xe_sriov_debugfs.c b/lib/xe/xe_sriov_debugfs.c
index c87f91492..92a477764 100644
--- a/lib/xe/xe_sriov_debugfs.c
+++ b/lib/xe/xe_sriov_debugfs.c
@@ -9,6 +9,7 @@
#include "drmtest.h"
#include "igt_debugfs.h"
#include "igt_sriov_device.h"
+#include "igt_sysfs.h"
#include "xe/xe_query.h"
#include "xe/xe_sriov_debugfs.h"
#include "xe/xe_sriov_provisioning.h"
@@ -204,3 +205,153 @@ cleanup:
return ret;
}
+
+static int xe_sriov_pf_debugfs_path_open(int pf, unsigned int vf_num,
+ unsigned int gt_num)
+{
+ char path[PATH_MAX];
+
+ if (igt_debug_on_f(!xe_sriov_pf_debugfs_path(pf, vf_num, gt_num, path,
+ sizeof(path)),
+ "path: %s\n", path))
+ return -1;
+
+ return open(path, O_RDONLY);
+}
+
+/**
+ * DEFINE_XE_SRIOV_PF_DEBUGFS_FUNC - Define a function for accessing debugfs attributes
+ * @type: Data type of the value to read or write (e.g., `uint32_t`, `bool`, etc.)
+ * @suffix: Function name suffix appended to `__xe_sriov_pf_debugfs_`
+ * @sysfs_func: The sysfs helper function to perform the actual read or write operation
+ *
+ * Generates a function for accessing a debugfs attribute of a PF device.
+ * It handles opening the debugfs path, performing the sysfs operation, and closing the
+ * debugfs directory.
+ *
+ * The generated function has the following signature:
+ *
+ * int __xe_sriov_pf_debugfs_<suffix>(int pf, unsigned int vf_num,
+ * unsigned int gt_num,
+ * const char *attr, type value)
+ *
+ * where:
+ * - `pf` is the PF device file descriptor.
+ * - `vf_num` is the VF number.
+ * - `gt_num` is the GT number.
+ * - `attr` is the name of the debugfs attribute.
+ * - `value` is the data to read or write, depending on the sysfs function.
+ *
+ * Example:
+ *
+ * DEFINE_XE_SRIOV_PF_DEBUGFS_FUNC(uint32_t, set_u32, __igt_sysfs_set_u32);
+ *
+ * This expands to a function:
+ *
+ * int __xe_sriov_pf_debugfs_set_u32(int pf, unsigned int vf_num,
+ * unsigned int gt_num,
+ * const char *attr, uint32_t value);
+ *
+ * The function returns:
+ * - `0` on success
+ * - Negative error code on failure
+ */
+#define DEFINE_XE_SRIOV_PF_DEBUGFS_FUNC(type, suffix, sysfs_func) \
+ int __xe_sriov_pf_debugfs_##suffix(int pf, unsigned int vf_num, \
+ unsigned int gt_num, \
+ const char *attr, type value) \
+ { \
+ bool ret; \
+ int dir = xe_sriov_pf_debugfs_path_open(pf, vf_num, gt_num); \
+ \
+ if (igt_debug_on(dir < 0)) \
+ return dir; \
+ \
+ ret = sysfs_func(dir, attr, value); \
+ close(dir); \
+ return ret ? 0 : -1; \
+ }
+
+/**
+ * __xe_sriov_pf_debugfs_get_u32 - Get a 32-bit unsigned integer from debugfs
+ * @pf: PF device file descriptor
+ * @vf_num: VF number
+ * @gt_num: GT number
+ * @attr: Debugfs attribute to read
+ * @value: Pointer to store the retrieved value
+ *
+ * Reads a 32-bit unsigned integer from the specified debugfs attribute.
+ *
+ * Return: 0 on success, negative error code on failure.
+ */
+DEFINE_XE_SRIOV_PF_DEBUGFS_FUNC(uint32_t *, get_u32, __igt_sysfs_get_u32)
+
+/**
+ * __xe_sriov_pf_debugfs_set_u32 - Set a 32-bit unsigned integer in debugfs
+ * @pf: PF device file descriptor
+ * @vf_num: VF number
+ * @gt_num: GT number
+ * @attr: Debugfs attribute to write to
+ * @value: The value to set
+ *
+ * Writes a 32-bit unsigned integer to the specified debugfs attribute.
+ *
+ * Return: 0 on success, negative error code on failure.
+ */
+DEFINE_XE_SRIOV_PF_DEBUGFS_FUNC(uint32_t, set_u32, __igt_sysfs_set_u32)
+
+/**
+ * __xe_sriov_pf_debugfs_get_u64 - Get a 64-bit unsigned integer from debugfs
+ * @pf: PF device file descriptor
+ * @vf_num: VF number
+ * @gt_num: GT number
+ * @attr: Debugfs attribute to read
+ * @value: Pointer to store the retrieved value
+ *
+ * Reads a 64-bit unsigned integer from the specified debugfs attribute.
+ *
+ * Return: 0 on success, negative error code on failure.
+ */
+DEFINE_XE_SRIOV_PF_DEBUGFS_FUNC(uint64_t *, get_u64, __igt_sysfs_get_u64)
+
+/**
+ * __xe_sriov_pf_debugfs_set_u64 - Set a 64-bit unsigned integer in debugfs
+ * @pf: PF device file descriptor
+ * @vf_num: VF number
+ * @gt_num: GT number
+ * @attr: Debugfs attribute to write to
+ * @value: The value to set
+ *
+ * Writes a 64-bit unsigned integer to the specified debugfs attribute.
+ *
+ * Return: 0 on success, negative error code on failure.
+ */
+DEFINE_XE_SRIOV_PF_DEBUGFS_FUNC(uint64_t, set_u64, __igt_sysfs_set_u64)
+
+/**
+ * __xe_sriov_pf_debugfs_get_boolean - Get a boolean value from debugfs
+ * @pf: PF device file descriptor
+ * @vf_num: VF number
+ * @gt_num: GT number
+ * @attr: Debugfs attribute to read
+ * @value: Pointer to store the retrieved value
+ *
+ * Reads a boolean value from the specified debugfs attribute.
+ *
+ * Return: 0 on success, negative error code on failure.
+ */
+DEFINE_XE_SRIOV_PF_DEBUGFS_FUNC(bool *, get_boolean, __igt_sysfs_get_boolean)
+
+/**
+ * __xe_sriov_pf_debugfs_set_boolean - Set a boolean value in debugfs
+ * @pf: PF device file descriptor
+ * @vf_num: VF number
+ * @gt_num: GT number
+ * @attr: Debugfs attribute to write to
+ * @value: The value to set
+ *
+ * Writes a boolean value to the specified debugfs attribute.
+ *
+ * Return: 0 on success, negative error code on failure.
+ */
+DEFINE_XE_SRIOV_PF_DEBUGFS_FUNC(bool, set_boolean, __igt_sysfs_set_boolean)
diff --git a/lib/xe/xe_sriov_debugfs.h b/lib/xe/xe_sriov_debugfs.h
index 856445e76..2db965f9b 100644
--- a/lib/xe/xe_sriov_debugfs.h
+++ b/lib/xe/xe_sriov_debugfs.h
@@ -16,5 +16,23 @@ int xe_sriov_pf_debugfs_read_provisioned_ranges(int pf_fd, enum xe_sriov_shared_
unsigned int gt_id,
struct xe_sriov_provisioned_range **ranges,
unsigned int *nr_ranges);
+int __xe_sriov_pf_debugfs_get_u32(int pf, unsigned int vf_num,
+ unsigned int gt_num, const char *attr,
+ uint32_t *value);
+int __xe_sriov_pf_debugfs_set_u32(int pf, unsigned int vf_num,
+ unsigned int gt_num, const char *attr,
+ uint32_t value);
+int __xe_sriov_pf_debugfs_get_u64(int pf, unsigned int vf_num,
+ unsigned int gt_num, const char *attr,
+ uint64_t *value);
+int __xe_sriov_pf_debugfs_set_u64(int pf, unsigned int vf_num,
+ unsigned int gt_num, const char *attr,
+ uint64_t value);
+int __xe_sriov_pf_debugfs_get_boolean(int pf, unsigned int vf_num,
+ unsigned int gt_num, const char *attr,
+ bool *value);
+int __xe_sriov_pf_debugfs_set_boolean(int pf, unsigned int vf_num,
+ unsigned int gt_num, const char *attr,
+ bool value);
#endif /* __XE_SRIOV_DEBUGFS_H__ */
--
2.31.1
next prev parent reply other threads:[~2025-01-14 15:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-14 15:08 [PATCH v2 i-g-t 0/7] Add xe_sriov_auto_provisioning tests Marcin Bernatowicz
2025-01-14 15:08 ` Marcin Bernatowicz [this message]
2025-01-14 15:08 ` [PATCH v2 i-g-t 2/7] lib/xe/xe_sriov_debugfs: Add validation for provisioned ranges Marcin Bernatowicz
2025-01-15 15:55 ` Laguna, Lukasz
2025-01-14 15:08 ` [PATCH v2 i-g-t 3/7] lib/xe/xe_sriov_provisioning: Add accessors for quota/spare attributes Marcin Bernatowicz
2025-01-14 15:08 ` [PATCH v2 i-g-t 4/7] lib/xe/xe_sriov_provisioning: Add shared resource provisionability check Marcin Bernatowicz
2025-01-14 15:08 ` [PATCH v2 i-g-t 5/7] lib/igt_sriov_device: Add helper functions for VF range validation Marcin Bernatowicz
2025-01-14 15:08 ` [PATCH v2 i-g-t 6/7] tests/xe_sriov_auto_provisioning: Add tests for SR-IOV auto-provisioning Marcin Bernatowicz
2025-01-15 15:57 ` Laguna, Lukasz
2025-01-14 15:08 ` [PATCH v2 i-g-t 7/7] tests/xe_sriov_auto_provisioning: Add 'extended' command line option Marcin Bernatowicz
2025-01-15 16:06 ` Laguna, Lukasz
2025-01-14 18:17 ` ✓ i915.CI.BAT: success for Add xe_sriov_auto_provisioning tests (rev2) Patchwork
2025-01-14 18:24 ` ✓ Xe.CI.BAT: " Patchwork
2025-01-14 20:53 ` ✗ Xe.CI.Full: failure " Patchwork
2025-01-15 13:04 ` ✗ 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=20250114150848.332708-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 \
--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 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.