summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/xe/xe_lmtt_types.h
blob: b37abad23416480ea5092f66aa45b15124f25646 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* SPDX-License-Identifier: MIT */
/*
 * Copyright © 2023 Intel Corporation
 */

#ifndef _XE_LMTT_TYPES_H_
#define _XE_LMTT_TYPES_H_

#include <linux/types.h>

struct xe_bo;
struct xe_lmtt;
struct xe_lmtt_pt;
struct xe_lmtt_ops;

#define LMTT_PTE_INVALID	ULL(0)

/**
 * struct xe_lmtt - Local Memory Translation Table Manager
 */
struct xe_lmtt {
	/** @pd: root LMTT Directory */
	struct xe_lmtt_pt *pd;

	/** @ops: LMTT functions */
	const struct xe_lmtt_ops *ops;
};

/**
 * struct xe_lmtt_pt - Local Memory Translation Table Page Table
 *
 * Represents single level of the LMTT.
 */
struct xe_lmtt_pt {
	/** @level: page table level, 0 is leaf */
	unsigned int level;

	/** @bo: buffer object with actual LMTT PTE values */
	struct xe_bo *bo;

	/** @entries: leaf page tables, exist only for root/non-leaf */
	struct xe_lmtt_pt *entries[];
};

/**
 * struct xe_lmtt_ops - Local Memory Translation Table Operations
 *
 * Provides abstraction of the LMTT variants.
 */
struct xe_lmtt_ops {
	/* private: */
	unsigned int (*lmtt_root_pd_level)(void);
	unsigned int (*lmtt_pte_num)(unsigned int level);
	unsigned int (*lmtt_pte_size)(unsigned int level);
	unsigned int (*lmtt_pte_shift)(unsigned int level);
	unsigned int (*lmtt_pte_index)(u64 addr, unsigned int level);
	u64 (*lmtt_pte_encode)(unsigned long offset, unsigned int level);
};

extern const struct xe_lmtt_ops lmtt_2l_ops;
extern const struct xe_lmtt_ops lmtt_ml_ops;

#endif