Skip to content

Commit c720172

Browse files
committed
drm/xe: Add helper to format SR-IOV function name
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
1 parent 5f36d1c commit c720172

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

drivers/gpu/drm/xe/xe_sriov.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,20 @@ void xe_sriov_print_info(struct xe_device *xe, struct drm_printer *p)
122122
drm_printf(p, "enabled: %s\n", str_yes_no(IS_SRIOV(xe)));
123123
drm_printf(p, "mode: %s\n", xe_sriov_mode_to_string(xe_device_sriov_mode(xe)));
124124
}
125+
126+
/**
127+
* xe_sriov_function_name() - Get SR-IOV Function name.
128+
* @n: the Function number (identifier) to get name of
129+
* @buf: the buffer to format to
130+
* @size: size of the buffer (shall be at least 5 bytes)
131+
*
132+
* Return: formatted function name ("PF" or "VF%u").
133+
*/
134+
const char *xe_sriov_function_name(unsigned int n, char *buf, size_t size)
135+
{
136+
if (n)
137+
snprintf(buf, size, "VF%u", n);
138+
else
139+
strscpy(buf, "PF", size);
140+
return buf;
141+
}

drivers/gpu/drm/xe/xe_sriov.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
struct drm_printer;
1414

1515
const char *xe_sriov_mode_to_string(enum xe_sriov_mode mode);
16+
const char *xe_sriov_function_name(unsigned int n, char *buf, size_t len);
1617

1718
void xe_sriov_probe_early(struct xe_device *xe);
1819
void xe_sriov_print_info(struct xe_device *xe, struct drm_printer *p);

0 commit comments

Comments
 (0)