]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/xe: Add helper to format SR-IOV function name
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Mon, 15 Apr 2024 17:39:32 +0000 (19:39 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 16 Apr 2024 10:37:28 +0000 (12:37 +0200)
While the GuC firmware and the Xe driver are using VF identifier
VFID(0) to represent the Physical Function, we should avoid using
"VF0" name and use proper "PF" name in all user facing messages
related to the Physical Function and use "VFn" name only when
referrinf to the true Virtual Function. Add simple helper to get
properly formatted function name based on the function number.

Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Reviewed-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240415173937.1287-2-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_sriov.c
drivers/gpu/drm/xe/xe_sriov.h

index 1b40f5de9ef593ced38f5d74d43bb014c4e6e80e..1c3fa84b6adb0fe638e24ac70a2b51570c204602 100644 (file)
@@ -122,3 +122,20 @@ void xe_sriov_print_info(struct xe_device *xe, struct drm_printer *p)
        drm_printf(p, "enabled: %s\n", str_yes_no(IS_SRIOV(xe)));
        drm_printf(p, "mode: %s\n", xe_sriov_mode_to_string(xe_device_sriov_mode(xe)));
 }
+
+/**
+ * xe_sriov_function_name() - Get SR-IOV Function name.
+ * @n: the Function number (identifier) to get name of
+ * @buf: the buffer to format to
+ * @size: size of the buffer (shall be at least 5 bytes)
+ *
+ * Return: formatted function name ("PF" or "VF%u").
+ */
+const char *xe_sriov_function_name(unsigned int n, char *buf, size_t size)
+{
+       if (n)
+               snprintf(buf, size, "VF%u", n);
+       else
+               strscpy(buf, "PF", size);
+       return buf;
+}
index f9dec84d77e3b1f660bb04955f17a0e4e6523e9d..486bb21c3256bfb886b6b08287291888f4d42fdc 100644 (file)
@@ -13,6 +13,7 @@
 struct drm_printer;
 
 const char *xe_sriov_mode_to_string(enum xe_sriov_mode mode);
+const char *xe_sriov_function_name(unsigned int n, char *buf, size_t len);
 
 void xe_sriov_probe_early(struct xe_device *xe);
 void xe_sriov_print_info(struct xe_device *xe, struct drm_printer *p);