1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2019 Intel Corporation. All rights rsvd. */
3 #ifndef _IDXD_REGISTERS_H_
4 #define _IDXD_REGISTERS_H_
6 #include <uapi/linux/idxd.h>
9 #define DEVICE_VERSION_1 0x100
10 #define DEVICE_VERSION_2 0x200
12 #define IDXD_MMIO_BAR 0
14 #define IDXD_PORTAL_SIZE PAGE_SIZE
16 /* MMIO Device BAR0 Registers */
17 #define IDXD_VER_OFFSET 0x00
18 #define IDXD_VER_MAJOR_MASK 0xf0
19 #define IDXD_VER_MINOR_MASK 0x0f
20 #define GET_IDXD_VER_MAJOR(x) (((x) & IDXD_VER_MAJOR_MASK) >> 4)
21 #define GET_IDXD_VER_MINOR(x) ((x) & IDXD_VER_MINOR_MASK)
27 u64 cache_control_mem:1;
28 u64 cache_control_cache:1;
35 u64 batch_continuation:1;
37 u64 max_batch_shift:4;
44 #define IDXD_GENCAP_OFFSET 0x10
64 #define IDXD_WQCAP_OFFSET 0x20
65 #define IDXD_WQCFG_MIN 5
70 u64 total_rdbufs:8; /* formerly total_tokens */
71 u64 rdbuf_ctrl:1; /* formerly token_en */
72 u64 rdbuf_limit:1; /* formerly token_limit */
73 u64 progress_limit:1; /* descriptor and batch descriptor */
78 #define IDXD_GRPCAP_OFFSET 0x30
80 union engine_cap_reg {
88 #define IDXD_ENGCAP_OFFSET 0x38
90 #define IDXD_OPCAP_NOOP 0x0001
91 #define IDXD_OPCAP_BATCH 0x0002
92 #define IDXD_OPCAP_MEMMOVE 0x0008
97 #define IDXD_MAX_OPCAP_BITS 256U
99 #define IDXD_OPCAP_OFFSET 0x40
101 #define IDXD_TABLE_OFFSET 0x60
114 #define IDXD_TABLE_MULT 0x100
116 #define IDXD_GENCFG_OFFSET 0x80
128 #define IDXD_GENCTRL_OFFSET 0x88
131 u32 softerr_int_en:1;
139 #define IDXD_GENSTATS_OFFSET 0x90
149 enum idxd_device_status_state {
150 IDXD_DEVICE_STATE_DISABLED = 0,
151 IDXD_DEVICE_STATE_ENABLED,
152 IDXD_DEVICE_STATE_DRAIN,
153 IDXD_DEVICE_STATE_HALT,
156 enum idxd_device_reset_type {
157 IDXD_DEVICE_RESET_SOFTWARE = 0,
158 IDXD_DEVICE_RESET_FLR,
159 IDXD_DEVICE_RESET_WARM,
160 IDXD_DEVICE_RESET_COLD,
163 #define IDXD_INTCAUSE_OFFSET 0x98
164 #define IDXD_INTC_ERR 0x01
165 #define IDXD_INTC_CMD 0x02
166 #define IDXD_INTC_OCCUPY 0x04
167 #define IDXD_INTC_PERFMON_OVFL 0x08
168 #define IDXD_INTC_HALT_STATE 0x10
169 #define IDXD_INTC_EVL 0x20
170 #define IDXD_INTC_INT_HANDLE_REVOKED 0x80000000
172 #define IDXD_CMD_OFFSET 0xa0
173 union idxd_command_reg {
184 IDXD_CMD_ENABLE_DEVICE = 1,
185 IDXD_CMD_DISABLE_DEVICE,
188 IDXD_CMD_RESET_DEVICE,
194 IDXD_CMD_DRAIN_PASID,
195 IDXD_CMD_ABORT_PASID,
196 IDXD_CMD_REQUEST_INT_HANDLE,
197 IDXD_CMD_RELEASE_INT_HANDLE,
200 #define CMD_INT_HANDLE_IMS 0x10000
202 #define IDXD_CMDSTS_OFFSET 0xa8
212 #define IDXD_CMDSTS_ACTIVE 0x80000000
213 #define IDXD_CMDSTS_ERR_MASK 0xff
214 #define IDXD_CMDSTS_RES_SHIFT 8
216 enum idxd_cmdsts_err {
217 IDXD_CMDSTS_SUCCESS = 0,
218 IDXD_CMDSTS_INVAL_CMD,
219 IDXD_CMDSTS_INVAL_WQIDX,
221 /* enable device errors */
222 IDXD_CMDSTS_ERR_DEV_ENABLED = 0x10,
223 IDXD_CMDSTS_ERR_CONFIG,
224 IDXD_CMDSTS_ERR_BUSMASTER_EN,
225 IDXD_CMDSTS_ERR_PASID_INVAL,
226 IDXD_CMDSTS_ERR_WQ_SIZE_ERANGE,
227 IDXD_CMDSTS_ERR_GRP_CONFIG,
228 IDXD_CMDSTS_ERR_GRP_CONFIG2,
229 IDXD_CMDSTS_ERR_GRP_CONFIG3,
230 IDXD_CMDSTS_ERR_GRP_CONFIG4,
231 /* enable wq errors */
232 IDXD_CMDSTS_ERR_DEV_NOTEN = 0x20,
233 IDXD_CMDSTS_ERR_WQ_ENABLED,
234 IDXD_CMDSTS_ERR_WQ_SIZE,
235 IDXD_CMDSTS_ERR_WQ_PRIOR,
236 IDXD_CMDSTS_ERR_WQ_MODE,
237 IDXD_CMDSTS_ERR_BOF_EN,
238 IDXD_CMDSTS_ERR_PASID_EN,
239 IDXD_CMDSTS_ERR_MAX_BATCH_SIZE,
240 IDXD_CMDSTS_ERR_MAX_XFER_SIZE,
241 /* disable device errors */
242 IDXD_CMDSTS_ERR_DIS_DEV_EN = 0x31,
243 /* disable WQ, drain WQ, abort WQ, reset WQ */
244 IDXD_CMDSTS_ERR_DEV_NOT_EN,
245 /* request interrupt handle */
246 IDXD_CMDSTS_ERR_INVAL_INT_IDX = 0x41,
247 IDXD_CMDSTS_ERR_NO_HANDLE,
250 #define IDXD_CMDCAP_OFFSET 0xb0
252 #define IDXD_SWERR_OFFSET 0xc0
253 #define IDXD_SWERR_VALID 0x00000001
254 #define IDXD_SWERR_OVERFLOW 0x00000002
255 #define IDXD_SWERR_ACK (IDXD_SWERR_VALID | IDXD_SWERR_OVERFLOW)
275 u64 invalid_flags:32;
286 u64 dec_aecs_format_ver:1;
287 u64 drop_init_bits:1;
289 u64 force_array_output_mod:1;
290 u64 load_part_aecs:1;
291 u64 comp_early_abort:1;
303 #define IDXD_IAACAP_OFFSET 0x180
305 #define IDXD_EVLCFG_OFFSET 0xe0
320 #define IDXD_EVL_SIZE_MIN 0x0040
321 #define IDXD_EVL_SIZE_MAX 0xffff
339 u64 use_rdbuf_limit:1;
340 u64 rdbufs_reserved:8;
342 u64 rdbufs_allowed:8;
344 u64 desc_progress_limit:2;
346 u64 batch_progress_limit:2;
355 union group_flags flags;
369 u32 mode:1; /* shared or dedicated */
370 u32 bof:1; /* block on fault */
371 u32 wq_ats_disable:1;
372 u32 wq_prs_disable:1;
380 u32 max_xfer_shift:5;
381 u32 max_batch_shift:4;
386 u16 occupancy_table_sel:1;
391 u16 occupancy_int_en:1;
410 #define WQCFG_PASID_IDX 2
411 #define WQCFG_PRIVL_IDX 2
412 #define WQCFG_OCCUP_IDX 6
414 #define WQCFG_OCCUP_MASK 0xffff
417 * This macro calculates the offset into the WQCFG register
418 * idxd - struct idxd *
420 * ofs - the index of the 32b dword for the config register
422 * The WQCFG register block is divided into groups per each wq. The n index
423 * allows us to move to the register group that's for that particular wq.
424 * Each register is 32bits. The ofs gives us the number of register to access.
426 #define WQCFG_OFFSET(_idxd_dev, n, ofs) \
428 typeof(_idxd_dev) __idxd_dev = (_idxd_dev); \
429 (__idxd_dev)->wqcfg_offset + (n) * (__idxd_dev)->wqcfg_size + sizeof(u32) * (ofs); \
432 #define WQCFG_STRIDES(_idxd_dev) ((_idxd_dev)->wqcfg_size / sizeof(u32))
434 #define GRPCFG_SIZE 64
435 #define GRPWQCFG_STRIDES 4
438 * This macro calculates the offset into the GRPCFG register
439 * idxd - struct idxd *
441 * ofs - the index of the 64b qword for the config register
443 * The GRPCFG register block is divided into three sub-registers, which
444 * are GRPWQCFG, GRPENGCFG and GRPFLGCFG. The n index allows us to move
445 * to the register block that contains the three sub-registers.
446 * Each register block is 64bits. And the ofs gives us the offset
447 * within the GRPWQCFG register to access.
449 #define GRPWQCFG_OFFSET(idxd_dev, n, ofs) ((idxd_dev)->grpcfg_offset +\
450 (n) * GRPCFG_SIZE + sizeof(u64) * (ofs))
451 #define GRPENGCFG_OFFSET(idxd_dev, n) ((idxd_dev)->grpcfg_offset + (n) * GRPCFG_SIZE + 32)
452 #define GRPFLGCFG_OFFSET(idxd_dev, n) ((idxd_dev)->grpcfg_offset + (n) * GRPCFG_SIZE + 40)
454 /* Following is performance monitor registers */
455 #define IDXD_PERFCAP_OFFSET 0x0
458 u64 num_perf_counter:6;
461 u64 num_event_category:4;
462 u64 global_event_category:16;
465 u64 cap_per_counter:1;
466 u64 writeable_counter:1;
467 u64 counter_freeze:1;
468 u64 overflow_interrupt:1;
474 #define IDXD_EVNTCAP_OFFSET 0x80
486 u32 event_category:4;
493 #define IDXD_CNTRCAP_OFFSET 0x800
494 struct idxd_cntrcap {
503 struct idxd_event events[];
506 #define IDXD_PERFRST_OFFSET 0x10
509 u32 perfrst_config:1;
510 u32 perfrst_counter:1;
516 #define IDXD_OVFSTATUS_OFFSET 0x30
517 #define IDXD_PERFFRZ_OFFSET 0x20
518 #define IDXD_CNTRCFG_OFFSET 0x100
523 u64 global_freeze_ovf:1;
525 u64 event_category:4;
533 #define IDXD_FLTCFG_OFFSET 0x300
535 #define IDXD_CNTRDATA_OFFSET 0x200
536 union idxd_cntrdata {
538 u64 event_count_value;
562 #define IDXD_EVLSTATUS_OFFSET 0xf0
564 union evl_status_reg {
580 #define IDXD_MAX_BATCH_IDENT 256
589 u64 err_info_valid:1;
600 /* Invalid Flags 0x11 */
602 /* Invalid Int Handle 0x19 */
603 /* Page fault 0x1a */
604 /* Page fault 0x06, 0x1f, only operand_id */
605 /* Page fault before drain or in batch, 0x26, 0x27 */
611 u16 first_err_in_batch:1;
620 struct dsa_evl_entry {
621 struct __evl_entry e;
622 struct dsa_completion_record cr;
625 struct iax_evl_entry {
626 struct __evl_entry e;
628 struct iax_completion_record cr;