1b9708648SEryk Brol /*
2b9708648SEryk Brol  * Copyright 2018 Advanced Micro Devices, Inc.
3b9708648SEryk Brol  *
4b9708648SEryk Brol  * Permission is hereby granted, free of charge, to any person obtaining a
5b9708648SEryk Brol  * copy of this software and associated documentation files (the "Software"),
6b9708648SEryk Brol  * to deal in the Software without restriction, including without limitation
7b9708648SEryk Brol  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8b9708648SEryk Brol  * and/or sell copies of the Software, and to permit persons to whom the
9b9708648SEryk Brol  * Software is furnished to do so, subject to the following conditions:
10b9708648SEryk Brol  *
11b9708648SEryk Brol  * The above copyright notice and this permission notice shall be included in
12b9708648SEryk Brol  * all copies or substantial portions of the Software.
13b9708648SEryk Brol  *
14b9708648SEryk Brol  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15b9708648SEryk Brol  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16b9708648SEryk Brol  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17b9708648SEryk Brol  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18b9708648SEryk Brol  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19b9708648SEryk Brol  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20b9708648SEryk Brol  * OTHER DEALINGS IN THE SOFTWARE.
21b9708648SEryk Brol  *
22b9708648SEryk Brol  * Authors: AMD
23b9708648SEryk Brol  *
24b9708648SEryk Brol  */
25b9708648SEryk Brol 
26b9708648SEryk Brol #ifndef DC_INC_VM_HELPER_H_
27b9708648SEryk Brol #define DC_INC_VM_HELPER_H_
28b9708648SEryk Brol 
29b9708648SEryk Brol #include "dc_types.h"
30b9708648SEryk Brol 
31b9708648SEryk Brol #define MAX_VMID 16
32b9708648SEryk Brol #define MAX_HUBP 6
33b9708648SEryk Brol 
34b9708648SEryk Brol struct vmid_usage {
35b9708648SEryk Brol 	uint16_t vmid_usage[2];
36b9708648SEryk Brol };
37b9708648SEryk Brol 
38b9708648SEryk Brol struct vm_helper {
39b9708648SEryk Brol 	unsigned int num_vmid;
40b9708648SEryk Brol 	unsigned int num_hubp;
41b9708648SEryk Brol 	unsigned int num_vmids_available;
4200fbeb4eSEryk Brol 	uint64_t ptb_assigned_to_vmid[MAX_VMID];
4300fbeb4eSEryk Brol 	struct vmid_usage hubp_vmid_usage[MAX_HUBP];
44b9708648SEryk Brol };
45b9708648SEryk Brol 
46b9708648SEryk Brol uint8_t get_vmid_for_ptb(
47b9708648SEryk Brol 		struct vm_helper *vm_helper,
48b9708648SEryk Brol 		int64_t ptb,
49b9708648SEryk Brol 		uint8_t pipe_idx);
50b9708648SEryk Brol 
5100fbeb4eSEryk Brol void init_vm_helper(
5200fbeb4eSEryk Brol 	struct vm_helper *vm_helper,
53b9708648SEryk Brol 	unsigned int num_vmid,
54b9708648SEryk Brol 	unsigned int num_hubp);
55b9708648SEryk Brol 
56b9708648SEryk Brol #endif /* DC_INC_VM_HELPER_H_ */
57