1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2023-2024 Intel Corporation
6 #ifndef _XE_SRIOV_PF_HELPERS_H_
7 #define _XE_SRIOV_PF_HELPERS_H_
10 #include "xe_device_types.h"
12 #include "xe_sriov_types.h"
15 * xe_sriov_pf_assert_vfid() - warn if &id is not a supported VF number when debugging.
16 * @xe: the PF &xe_device to assert on
17 * @vfid: the VF number to assert
19 * Assert that &xe represents the Physical Function (PF) device and provided &vfid
20 * is within a range of supported VF numbers (up to maximum number of VFs that
21 * driver can support, including VF0 that represents the PF itself).
23 * Note: Effective only on debug builds. See `Xe ASSERTs`_ for more information.
25 #define xe_sriov_pf_assert_vfid(xe, vfid) \
26 xe_assert((xe), (vfid) <= xe_sriov_pf_get_totalvfs(xe))
29 * xe_sriov_pf_get_totalvfs() - Get maximum number of VFs that driver can support.
30 * @xe: the &xe_device to query (shall be PF)
32 * Return: Maximum number of VFs that this PF driver supports.
34 static inline int xe_sriov_pf_get_totalvfs(struct xe_device *xe)
36 xe_assert(xe, IS_SRIOV_PF(xe));
37 return xe->sriov.pf.driver_max_vfs;
40 static inline struct mutex *xe_sriov_pf_master_mutex(struct xe_device *xe)
42 xe_assert(xe, IS_SRIOV_PF(xe));
43 return &xe->sriov.pf.master_lock;