1/* SPDX-License-Identifier: MIT */
2/*
3 * Copyright © 2023 Intel Corporation
4 */
5
6#ifndef _XE_LMTT_TYPES_H_
7#define _XE_LMTT_TYPES_H_
8
9#include <linux/types.h>
10
11struct xe_bo;
12struct xe_lmtt;
13struct xe_lmtt_pt;
14struct xe_lmtt_ops;
15
16#define LMTT_PTE_INVALID ULL(0)
17
18/**
19 * struct xe_lmtt - Local Memory Translation Table Manager
20 */
21struct xe_lmtt {
22 /** @pd: root LMTT Directory */
23 struct xe_lmtt_pt *pd;
24
25 /** @ops: LMTT functions */
26 const struct xe_lmtt_ops *ops;
27};
28
29/**
30 * struct xe_lmtt_pt - Local Memory Translation Table Page Table
31 *
32 * Represents single level of the LMTT.
33 */
34struct xe_lmtt_pt {
35 /** @level: page table level, 0 is leaf */
36 unsigned int level;
37
38 /** @bo: buffer object with actual LMTT PTE values */
39 struct xe_bo *bo;
40
41 /** @entries: leaf page tables, exist only for root/non-leaf */
42 struct xe_lmtt_pt *entries[];
43};
44
45/**
46 * struct xe_lmtt_ops - Local Memory Translation Table Operations
47 *
48 * Provides abstraction of the LMTT variants.
49 */
50struct xe_lmtt_ops {
51 /* private: */
52 unsigned int (*lmtt_root_pd_level)(void);
53 unsigned int (*lmtt_pte_num)(unsigned int level);
54 unsigned int (*lmtt_pte_size)(unsigned int level);
55 unsigned int (*lmtt_pte_shift)(unsigned int level);
56 unsigned int (*lmtt_pte_index)(u64 addr, unsigned int level);
57 u64 (*lmtt_pte_encode)(unsigned long offset, unsigned int level);
58};
59
60extern const struct xe_lmtt_ops lmtt_2l_ops;
61extern const struct xe_lmtt_ops lmtt_ml_ops;
62
63#endif
64

source code of linux/drivers/gpu/drm/xe/xe_lmtt_types.h