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,
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 1/5] lib/xe_sriov_debugfs: add helper for opening attributes
Date: Wed, 30 Oct 2024 20:36:25 +0100 [thread overview]
Message-ID: <20241030193629.1238637-2-marcin.bernatowicz@linux.intel.com> (raw)
In-Reply-To: <20241030193629.1238637-1-marcin.bernatowicz@linux.intel.com>
From: Lukasz Laguna <lukasz.laguna@intel.com>
Helper allows to open SR-IOV debugfs attributes corresponding to
specified PF device, VF number and GT number.
Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com>
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: 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/meson.build | 1 +
lib/xe/xe_sriov_debugfs.c | 69 +++++++++++++++++++++++++++++++++++++++
lib/xe/xe_sriov_debugfs.h | 14 ++++++++
3 files changed, 84 insertions(+)
create mode 100644 lib/xe/xe_sriov_debugfs.c
create mode 100644 lib/xe/xe_sriov_debugfs.h
diff --git a/lib/meson.build b/lib/meson.build
index c3556a921..3d5d68b75 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -116,6 +116,7 @@ lib_sources = [
'xe/xe_mmio.c',
'xe/xe_query.c',
'xe/xe_spin.c',
+ 'xe/xe_sriov_debugfs.c',
'xe/xe_util.c',
]
diff --git a/lib/xe/xe_sriov_debugfs.c b/lib/xe/xe_sriov_debugfs.c
new file mode 100644
index 000000000..dc6ef9da3
--- /dev/null
+++ b/lib/xe/xe_sriov_debugfs.c
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright(c) 2024 Intel Corporation. All rights reserved.
+ */
+
+#include <dirent.h>
+#include <fcntl.h>
+
+#include "drmtest.h"
+#include "igt_debugfs.h"
+#include "igt_sriov_device.h"
+#include "xe/xe_sriov_debugfs.h"
+#include "xe/xe_query.h"
+
+#define SRIOV_DEBUGFS_PATH_MAX 96
+
+static char *xe_sriov_pf_debugfs_path(int pf, unsigned int vf_num, unsigned int gt_num, char *path,
+ int pathlen)
+{
+ char sriov_path[SRIOV_DEBUGFS_PATH_MAX];
+
+ if (!igt_debugfs_path(pf, path, pathlen))
+ return NULL;
+
+ if (vf_num)
+ snprintf(sriov_path, SRIOV_DEBUGFS_PATH_MAX, "/gt%u/vf%u/", gt_num, vf_num);
+ else
+ snprintf(sriov_path, SRIOV_DEBUGFS_PATH_MAX, "/gt%u/pf/", gt_num);
+
+ strncat(path, sriov_path, pathlen - strlen(path));
+
+ if (access(path, F_OK))
+ return NULL;
+
+ return path;
+}
+
+/**
+ * xe_sriov_pf_debugfs_attr_open:
+ * @pf: PF device file descriptor
+ * @vf_num: VF number (1-based) or 0 for PF
+ * @gt_num: GT number
+ * @attr: debugfs attribute name
+ * @mode: mode bits as used by open()
+ *
+ * Opens SR-IOV debugfs attribute @attr for given PF device @pf, VF number @vf_num on GT @gt_num.
+ *
+ * Returns:
+ * File descriptor or -1 on failure.
+ */
+int xe_sriov_pf_debugfs_attr_open(int pf, unsigned int vf_num, unsigned int gt_num,
+ const char *attr, int mode)
+{
+ char path[PATH_MAX];
+ int debugfs;
+
+ igt_assert(igt_sriov_is_pf(pf) && is_xe_device(pf));
+ igt_assert(gt_num < xe_number_gt(pf));
+
+ if (!xe_sriov_pf_debugfs_path(pf, vf_num, gt_num, path, sizeof(path)))
+ return -1;
+
+ strncat(path, attr, sizeof(path) - strlen(path));
+
+ debugfs = open(path, mode);
+ igt_debug_on(debugfs < 0);
+
+ return debugfs;
+}
diff --git a/lib/xe/xe_sriov_debugfs.h b/lib/xe/xe_sriov_debugfs.h
new file mode 100644
index 000000000..e859ff5b2
--- /dev/null
+++ b/lib/xe/xe_sriov_debugfs.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2024 Intel Corporation. All rights reserved.
+ */
+
+#ifndef __XE_SRIOV_DEBUGFS_H__
+#define __XE_SRIOV_DEBUGFS_H__
+
+#include <stdint.h>
+
+int xe_sriov_pf_debugfs_attr_open(int pf, unsigned int vf_num, unsigned int gt_num,
+ const char *attr, int mode);
+
+#endif /* __XE_SRIOV_DEBUGFS_H__ */
--
2.31.1
next prev parent reply other threads:[~2024-10-30 19:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-30 19:36 [PATCH i-g-t 0/5] Add debugfs SR-IOV helpers; Improve clear-lmem check Marcin Bernatowicz
2024-10-30 19:36 ` Marcin Bernatowicz [this message]
2024-10-31 10:28 ` [PATCH i-g-t 1/5] lib/xe_sriov_debugfs: add helper for opening attributes Kamil Konieczny
2024-11-05 8:45 ` Adam Miszczak
2024-10-30 19:36 ` [PATCH i-g-t 2/5] lib/xe/xe_sriov_provisioning: Define resource types and provisioned range structure Marcin Bernatowicz
2024-11-05 11:21 ` Adam Miszczak
2024-11-06 9:09 ` Bernatowicz, Marcin
2024-10-30 19:36 ` [PATCH i-g-t 3/5] lib/xe/xe_sriov_debugfs: Add function to read provisioned ranges Marcin Bernatowicz
2024-11-05 11:39 ` Adam Miszczak
2024-10-30 19:36 ` [PATCH i-g-t 4/5] tests/intel/xe_sriov_flr: Verify full LMEM range Marcin Bernatowicz
2024-11-06 8:31 ` Adam Miszczak
2024-10-30 19:36 ` [PATCH i-g-t 5/5] lib/xe/xe_sriov_provisioning: Extract function to search provisioned PTE ranges Marcin Bernatowicz
2024-11-06 8:08 ` Adam Miszczak
2024-10-30 21:41 ` ✓ Fi.CI.BAT: success for Add debugfs SR-IOV helpers; Improve clear-lmem check Patchwork
2024-10-30 21:42 ` ✓ CI.xeBAT: " Patchwork
2024-10-30 23:20 ` ✗ CI.xeFULL: failure " Patchwork
2024-10-31 7:15 ` ✗ Fi.CI.IGT: " 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=20241030193629.1238637-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox