xref: /linux/drivers/gpu/drm/xe/xe_sriov.h (revision 508ecc78b6c983a7921bee2f4bd22682f9f0396e)
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 const char *xe_sriov_mode_to_string(enum xe_sriov_mode mode);
14 
15 void xe_sriov_probe_early(struct xe_device *xe, bool has_sriov);
16 
17 static inline enum xe_sriov_mode xe_device_sriov_mode(struct xe_device *xe)
18 {
19 	xe_assert(xe, xe->sriov.__mode);
20 	return xe->sriov.__mode;
21 }
22 
23 static inline bool xe_device_is_sriov_pf(struct xe_device *xe)
24 {
25 	return xe_device_sriov_mode(xe) == XE_SRIOV_MODE_PF;
26 }
27 
28 static inline bool xe_device_is_sriov_vf(struct xe_device *xe)
29 {
30 	return xe_device_sriov_mode(xe) == XE_SRIOV_MODE_VF;
31 }
32 
33 #ifdef CONFIG_PCI_IOV
34 #define IS_SRIOV_PF(xe) xe_device_is_sriov_pf(xe)
35 #else
36 #define IS_SRIOV_PF(xe) (typecheck(struct xe_device *, (xe)) && false)
37 #endif
38 #define IS_SRIOV_VF(xe) xe_device_is_sriov_vf(xe)
39 
40 #define IS_SRIOV(xe) (IS_SRIOV_PF(xe) || IS_SRIOV_VF(xe))
41 
42 #endif
43