-
Notifications
You must be signed in to change notification settings - Fork 9
/
ioctl.h
217 lines (174 loc) · 5.25 KB
/
ioctl.h
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
// SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
// SPDX-License-Identifier: GPL-2.0-only
#ifndef TTDRIVER_IOCTL_H_INCLUDED
#define TTDRIVER_IOCTL_H_INCLUDED
#include <linux/types.h>
#include <linux/ioctl.h>
#define TENSTORRENT_DRIVER_VERSION 1
#define TENSTORRENT_IOCTL_MAGIC 0xFA
#define TENSTORRENT_IOCTL_GET_DEVICE_INFO _IO(TENSTORRENT_IOCTL_MAGIC, 0)
#define TENSTORRENT_IOCTL_GET_HARVESTING _IO(TENSTORRENT_IOCTL_MAGIC, 1)
#define TENSTORRENT_IOCTL_QUERY_MAPPINGS _IO(TENSTORRENT_IOCTL_MAGIC, 2)
#define TENSTORRENT_IOCTL_ALLOCATE_DMA_BUF _IO(TENSTORRENT_IOCTL_MAGIC, 3)
#define TENSTORRENT_IOCTL_FREE_DMA_BUF _IO(TENSTORRENT_IOCTL_MAGIC, 4)
#define TENSTORRENT_IOCTL_GET_DRIVER_INFO _IO(TENSTORRENT_IOCTL_MAGIC, 5)
#define TENSTORRENT_IOCTL_RESET_DEVICE _IO(TENSTORRENT_IOCTL_MAGIC, 6)
#define TENSTORRENT_IOCTL_PIN_PAGES _IO(TENSTORRENT_IOCTL_MAGIC, 7)
#define TENSTORRENT_IOCTL_LOCK_CTL _IO(TENSTORRENT_IOCTL_MAGIC, 8)
#define TENSTORRENT_IOCTL_MAP_PEER_BAR _IO(TENSTORRENT_IOCTL_MAGIC, 9)
#define TENSTORRENT_IOCTL_UNPIN_PAGES _IO(TENSTORRENT_IOCTL_MAGIC, 10)
// For tenstorrent_mapping.mapping_id. These are not array indices.
#define TENSTORRENT_MAPPING_UNUSED 0
#define TENSTORRENT_MAPPING_RESOURCE0_UC 1
#define TENSTORRENT_MAPPING_RESOURCE0_WC 2
#define TENSTORRENT_MAPPING_RESOURCE1_UC 3
#define TENSTORRENT_MAPPING_RESOURCE1_WC 4
#define TENSTORRENT_MAPPING_RESOURCE2_UC 5
#define TENSTORRENT_MAPPING_RESOURCE2_WC 6
#define TENSTORRENT_MAX_DMA_BUFS 256
#define TENSTORRENT_RESOURCE_LOCK_COUNT 64
struct tenstorrent_get_device_info_in {
__u32 output_size_bytes;
};
struct tenstorrent_get_device_info_out {
__u32 output_size_bytes;
__u16 vendor_id;
__u16 device_id;
__u16 subsystem_vendor_id;
__u16 subsystem_id;
__u16 bus_dev_fn; // [0:2] function, [3:7] device, [8:15] bus
__u16 max_dma_buf_size_log2; // Since 1.0
__u16 pci_domain; // Since 1.23
};
struct tenstorrent_get_device_info {
struct tenstorrent_get_device_info_in in;
struct tenstorrent_get_device_info_out out;
};
struct tenstorrent_query_mappings_in {
__u32 output_mapping_count;
__u32 reserved;
};
struct tenstorrent_mapping {
__u32 mapping_id;
__u32 reserved;
__u64 mapping_base;
__u64 mapping_size;
};
struct tenstorrent_query_mappings_out {
struct tenstorrent_mapping mappings[0];
};
struct tenstorrent_query_mappings {
struct tenstorrent_query_mappings_in in;
struct tenstorrent_query_mappings_out out;
};
struct tenstorrent_allocate_dma_buf_in {
__u32 requested_size;
__u8 buf_index; // [0,TENSTORRENT_MAX_DMA_BUFS)
__u8 reserved0[3];
__u64 reserved1[2];
};
struct tenstorrent_allocate_dma_buf_out {
__u64 physical_address;
__u64 mapping_offset;
__u32 size;
__u32 reserved0;
__u64 reserved1[2];
};
struct tenstorrent_allocate_dma_buf {
struct tenstorrent_allocate_dma_buf_in in;
struct tenstorrent_allocate_dma_buf_out out;
};
struct tenstorrent_free_dma_buf_in {
};
struct tenstorrent_free_dma_buf_out {
};
struct tenstorrent_free_dma_buf {
struct tenstorrent_free_dma_buf_in in;
struct tenstorrent_free_dma_buf_out out;
};
struct tenstorrent_get_driver_info_in {
__u32 output_size_bytes;
};
struct tenstorrent_get_driver_info_out {
__u32 output_size_bytes;
__u32 driver_version;
};
struct tenstorrent_get_driver_info {
struct tenstorrent_get_driver_info_in in;
struct tenstorrent_get_driver_info_out out;
};
// tenstorrent_reset_device_in.flags
#define TENSTORRENT_RESET_DEVICE_RESTORE_STATE 0
#define TENSTORRENT_RESET_DEVICE_RESET_PCIE_LINK 1
#define TENSTORRENT_RESET_DEVICE_CONFIG_WRITE 2
struct tenstorrent_reset_device_in {
__u32 output_size_bytes;
__u32 flags;
};
struct tenstorrent_reset_device_out {
__u32 output_size_bytes;
__u32 result;
};
struct tenstorrent_reset_device {
struct tenstorrent_reset_device_in in;
struct tenstorrent_reset_device_out out;
};
// tenstorrent_pin_pages_in.flags
#define TENSTORRENT_PIN_PAGES_CONTIGUOUS 1 // app attests that the pages are physically contiguous
struct tenstorrent_pin_pages_in {
__u32 output_size_bytes;
__u32 flags;
__u64 virtual_address;
__u64 size;
};
struct tenstorrent_pin_pages_out {
__u64 physical_address;
};
// unpinning subset of a pinned buffer is not supported
struct tenstorrent_unpin_pages_in {
__u64 virtual_address; // original VA used to pin, not current VA if remapped
__u64 size;
__u64 reserved;
};
struct tenstorrent_unpin_pages_out {
};
struct tenstorrent_unpin_pages {
struct tenstorrent_unpin_pages_in in;
struct tenstorrent_unpin_pages_out out;
};
struct tenstorrent_pin_pages {
struct tenstorrent_pin_pages_in in;
struct tenstorrent_pin_pages_out out;
};
// tenstorrent_lock_ctl_in.flags
#define TENSTORRENT_LOCK_CTL_ACQUIRE 0
#define TENSTORRENT_LOCK_CTL_RELEASE 1
#define TENSTORRENT_LOCK_CTL_TEST 2
struct tenstorrent_lock_ctl_in {
__u32 output_size_bytes;
__u32 flags;
__u8 index;
};
struct tenstorrent_lock_ctl_out {
__u8 value;
};
struct tenstorrent_lock_ctl {
struct tenstorrent_lock_ctl_in in;
struct tenstorrent_lock_ctl_out out;
};
struct tenstorrent_map_peer_bar_in {
__u32 peer_fd;
__u32 peer_bar_index;
__u32 peer_bar_offset;
__u32 peer_bar_length;
__u32 flags;
};
struct tenstorrent_map_peer_bar_out {
__u64 dma_address;
__u64 reserved;
};
struct tenstorrent_map_peer_bar {
struct tenstorrent_map_peer_bar_in in;
struct tenstorrent_map_peer_bar_out out;
};
#endif