xref: /linux/drivers/gpu/drm/xe/xe_sriov.h (revision 53597deca0e38c30e6cd4ba2114fa42d2bcd85bb)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2023 Intel Corporation
4  */
5 
6 #ifndef _XE_SRIOV_H_
7 #define _XE_SRIOV_H_
8 
9 #include "xe_assert.h"
10 #include "xe_device_types.h"
11 #include "xe_sriov_types.h"
12 
13 struct drm_printer;
14 
15 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);
17 
18 void xe_sriov_probe_early(struct xe_device *xe);
19 void xe_sriov_print_info(struct xe_device *xe, struct drm_printer *p);
20 int xe_sriov_init(struct xe_device *xe);
21 int xe_sriov_init_late(struct xe_device *xe);
22 
23 static inline enum xe_sriov_mode xe_device_sriov_mode(const struct xe_device *xe)
24 {
25 	xe_assert(xe, xe->sriov.__mode);
26 	return xe->sriov.__mode;
27 }
28 
29 static inline bool xe_device_is_sriov_pf(const struct xe_device *xe)
30 {
31 	return IS_ENABLED(CONFIG_PCI_IOV) &&
32 		xe_device_sriov_mode(xe) == XE_SRIOV_MODE_PF;
33 }
34 
35 static inline bool xe_device_is_sriov_vf(const struct xe_device *xe)
36 {
37 	return xe_device_sriov_mode(xe) == XE_SRIOV_MODE_VF;
38 }
39 
40 #define IS_SRIOV_PF(xe) xe_device_is_sriov_pf(xe)
41 #define IS_SRIOV_VF(xe) xe_device_is_sriov_vf(xe)
42 
43 #define IS_SRIOV(xe) (IS_SRIOV_PF(xe) || IS_SRIOV_VF(xe))
44 
45 #endif
46