<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 30.10.2024 20:36, Marcin Bernatowicz
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:20241030193629.1238637-3-marcin.bernatowicz@linux.intel.com">
<pre wrap="" class="moz-quote-pre">Add shared resource enumeration, provisioned range structure definition,
and provide a function to convert shared resource enums to their string
representation. These types will be used in a subsequent patch to read
VF provisioned resources from the debug filesystem.
Signed-off-by: Marcin Bernatowicz <a class="moz-txt-link-rfc2396E" href="mailto:marcin.bernatowicz@linux.intel.com"><marcin.bernatowicz@linux.intel.com></a>
Cc: Adam Miszczak <a class="moz-txt-link-rfc2396E" href="mailto:adam.miszczak@linux.intel.com"><adam.miszczak@linux.intel.com></a>
Cc: Jakub Kolakowski <a class="moz-txt-link-rfc2396E" href="mailto:jakub1.kolakowski@intel.com"><jakub1.kolakowski@intel.com></a>
Cc: Marcin Bernatowicz <a class="moz-txt-link-rfc2396E" href="mailto:marcin.bernatowicz@linux.intel.com"><marcin.bernatowicz@linux.intel.com></a>
Cc: Michał Wajdeczko <a class="moz-txt-link-rfc2396E" href="mailto:michal.wajdeczko@intel.com"><michal.wajdeczko@intel.com></a>
Cc: Michał Winiarski <a class="moz-txt-link-rfc2396E" href="mailto:michal.winiarski@intel.com"><michal.winiarski@intel.com></a>
Cc: Narasimha C V <a class="moz-txt-link-rfc2396E" href="mailto:narasimha.c.v@intel.com"><narasimha.c.v@intel.com></a>
Cc: Piotr Piórkowski <a class="moz-txt-link-rfc2396E" href="mailto:piotr.piorkowski@intel.com"><piotr.piorkowski@intel.com></a>
Cc: Satyanarayana K V P <a class="moz-txt-link-rfc2396E" href="mailto:satyanarayana.k.v.p@intel.com"><satyanarayana.k.v.p@intel.com></a>
Cc: Tomasz Lis <a class="moz-txt-link-rfc2396E" href="mailto:tomasz.lis@intel.com"><tomasz.lis@intel.com></a>
---
lib/meson.build | 1 +
lib/xe/xe_sriov_provisioning.c | 33 +++++++++++++++++++++++++
lib/xe/xe_sriov_provisioning.h | 45 ++++++++++++++++++++++++++++++++++
3 files changed, 79 insertions(+)
create mode 100644 lib/xe/xe_sriov_provisioning.c
create mode 100644 lib/xe/xe_sriov_provisioning.h
diff --git a/lib/meson.build b/lib/meson.build
index 3d5d68b75..3d459c7a3 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -117,6 +117,7 @@ lib_sources = [
'xe/xe_query.c',
'xe/xe_spin.c',
'xe/xe_sriov_debugfs.c',
+ 'xe/xe_sriov_provisioning.c',
'xe/xe_util.c',
]
diff --git a/lib/xe/xe_sriov_provisioning.c b/lib/xe/xe_sriov_provisioning.c
new file mode 100644
index 000000000..6a9ad411a
--- /dev/null
+++ b/lib/xe/xe_sriov_provisioning.c
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright(c) 2024 Intel Corporation. All rights reserved.
+ */
+
+#include <stdlib.h>
+
+#include "xe/xe_sriov_provisioning.h"
+
+/**
+ * xe_sriov_shared_res_to_string:
+ * @key: The shared resource of type enum xe_sriov_shared_res
+ *
+ * Converts a shared resource enum to its corresponding string
+ * representation. It is useful for logging and debugging purposes.
+ *
+ * Return: A string representing the shared resource key.
+ */
+const char *xe_sriov_shared_res_to_string(enum xe_sriov_shared_res res)
+{
+ switch (res) {
+ case XE_SRIOV_SHARED_RES_CONTEXTS:
+ return "contexts";
+ case XE_SRIOV_SHARED_RES_DOORBELLS:
+ return "doorbells";
+ case XE_SRIOV_SHARED_RES_GGTT:
+ return "ggtt";
+ case XE_SRIOV_SHARED_RES_LMEM:
+ return "lmem";
+ }
+
+ return NULL;
+}
diff --git a/lib/xe/xe_sriov_provisioning.h b/lib/xe/xe_sriov_provisioning.h
new file mode 100644
index 000000000..7b7b3db90
--- /dev/null
+++ b/lib/xe/xe_sriov_provisioning.h
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright(c) 2024 Intel Corporation. All rights reserved.
+ */
+
+#ifndef __XE_SRIOV_PROVISIONING_H__
+#define __XE_SRIOV_PROVISIONING_H__
+
+#include <stdint.h>
+
+/**
+ * enum xe_sriov_shared_res - Shared resource types
+ * @XE_SRIOV_SHARED_RES_CONTEXTS: Contexts
+ * @XE_SRIOV_SHARED_RES_DOORBELLS: Doorbells
+ * @XE_SRIOV_SHARED_RES_GGTT: GGTT (Global Graphics Translation Table)
+ * @XE_SRIOV_SHARED_RES_LMEM: Local memory
+ *
+ * This enumeration defines the types of shared resources
+ * that can be provisioned to Virtual Functions (VFs).
+ */
+enum xe_sriov_shared_res {
+ XE_SRIOV_SHARED_RES_CONTEXTS,
+ XE_SRIOV_SHARED_RES_DOORBELLS,
+ XE_SRIOV_SHARED_RES_GGTT,
+ XE_SRIOV_SHARED_RES_LMEM,
+};
+
+/**
+ * struct xe_sriov_provisioned_range - Provisioned range for a Virtual Function (VF)
+ * @vf_id: The ID of the VF
+ * @start: The inclusive start of the provisioned range
+ * @end: The inclusive end of the provisioned range
+ *
+ * This structure represents a range of resources that have been provisioned
+ * for a specific VF, with both start and end values included in the range.
+ */
+struct xe_sriov_provisioned_range {
+ unsigned int vf_id;
+ uint64_t start;
+ uint64_t end;
+};
+</pre>
</blockquote>
<p>Debugfs *_provisioned attributes carry also some additional data
(e.g. number of ctxs or ggtt size) which is not covered here.<br>
I understand it's not used by tests now, but assume this could be
extended if there's such demand (e.g. some test needs it), right?<span
style="white-space: pre-wrap">
</span></p>
<blockquote type="cite"
cite="mid:20241030193629.1238637-3-marcin.bernatowicz@linux.intel.com">
<pre wrap="" class="moz-quote-pre">+const char *xe_sriov_shared_res_to_string(enum xe_sriov_shared_res res);</pre>
</blockquote>
Is this really required as an interface? Is this used anywhere?<br>
<blockquote type="cite"
cite="mid:20241030193629.1238637-3-marcin.bernatowicz@linux.intel.com">
<pre wrap="" class="moz-quote-pre">
+
+#endif /* __XE_SRIOV_PROVISIONING_H__ */</pre>
</blockquote>
<p>Overall, LGTM:<br>
Reviewed-by: Adam Miszczak <a class="moz-txt-link-rfc2396E"
href="mailto:adam.miszczak@linux.intel.com"><adam.miszczak@linux.intel.com></a></p>
<p><br>
</p>
</body>
</html>