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_
7 #define PCI_DEVICE_ID_INTEL_DSA_SPR0 0x0b25
8 #define PCI_DEVICE_ID_INTEL_IAX_SPR0 0x0cfe
10 #define DEVICE_VERSION_1 0x100
11 #define DEVICE_VERSION_2 0x200
13 #define IDXD_MMIO_BAR 0
15 #define IDXD_PORTAL_SIZE PAGE_SIZE
17 /* MMIO Device BAR0 Registers */
18 #define IDXD_VER_OFFSET 0x00
19 #define IDXD_VER_MAJOR_MASK 0xf0
20 #define IDXD_VER_MINOR_MASK 0x0f
21 #define GET_IDXD_VER_MAJOR(x) (((x) & IDXD_VER_MAJOR_MASK) >> 4)
22 #define GET_IDXD_VER_MINOR(x) ((x) & IDXD_VER_MINOR_MASK)
28 u64 cache_control_mem:1;
29 u64 cache_control_cache:1;
36 u64 max_batch_shift:4;
39 u64 max_descs_per_engine:8;
44 #define IDXD_GENCAP_OFFSET 0x10
62 #define IDXD_WQCAP_OFFSET 0x20
63 #define IDXD_WQCFG_MIN 5
75 #define IDXD_GRPCAP_OFFSET 0x30
77 union engine_cap_reg {
85 #define IDXD_ENGCAP_OFFSET 0x38
87 #define IDXD_OPCAP_NOOP 0x0001
88 #define IDXD_OPCAP_BATCH 0x0002
89 #define IDXD_OPCAP_MEMMOVE 0x0008
94 #define IDXD_OPCAP_OFFSET 0x40
96 #define IDXD_TABLE_OFFSET 0x60
109 #define IDXD_TABLE_MULT 0x100
111 #define IDXD_GENCFG_OFFSET 0x80
122 #define IDXD_GENCTRL_OFFSET 0x88
125 u32 softerr_int_en:1;
132 #define IDXD_GENSTATS_OFFSET 0x90
142 enum idxd_device_status_state {
143 IDXD_DEVICE_STATE_DISABLED = 0,
144 IDXD_DEVICE_STATE_ENABLED,
145 IDXD_DEVICE_STATE_DRAIN,
146 IDXD_DEVICE_STATE_HALT,
149 enum idxd_device_reset_type {
150 IDXD_DEVICE_RESET_SOFTWARE = 0,
151 IDXD_DEVICE_RESET_FLR,
152 IDXD_DEVICE_RESET_WARM,
153 IDXD_DEVICE_RESET_COLD,
156 #define IDXD_INTCAUSE_OFFSET 0x98
157 #define IDXD_INTC_ERR 0x01
158 #define IDXD_INTC_CMD 0x02
159 #define IDXD_INTC_OCCUPY 0x04
160 #define IDXD_INTC_PERFMON_OVFL 0x08
162 #define IDXD_CMD_OFFSET 0xa0
163 union idxd_command_reg {
174 IDXD_CMD_ENABLE_DEVICE = 1,
175 IDXD_CMD_DISABLE_DEVICE,
178 IDXD_CMD_RESET_DEVICE,
184 IDXD_CMD_DRAIN_PASID,
185 IDXD_CMD_ABORT_PASID,
186 IDXD_CMD_REQUEST_INT_HANDLE,
187 IDXD_CMD_RELEASE_INT_HANDLE,
190 #define CMD_INT_HANDLE_IMS 0x10000
192 #define IDXD_CMDSTS_OFFSET 0xa8
202 #define IDXD_CMDSTS_ACTIVE 0x80000000
203 #define IDXD_CMDSTS_ERR_MASK 0xff
204 #define IDXD_CMDSTS_RES_SHIFT 8
206 enum idxd_cmdsts_err {
207 IDXD_CMDSTS_SUCCESS = 0,
208 IDXD_CMDSTS_INVAL_CMD,
209 IDXD_CMDSTS_INVAL_WQIDX,
211 /* enable device errors */
212 IDXD_CMDSTS_ERR_DEV_ENABLED = 0x10,
213 IDXD_CMDSTS_ERR_CONFIG,
214 IDXD_CMDSTS_ERR_BUSMASTER_EN,
215 IDXD_CMDSTS_ERR_PASID_INVAL,
216 IDXD_CMDSTS_ERR_WQ_SIZE_ERANGE,
217 IDXD_CMDSTS_ERR_GRP_CONFIG,
218 IDXD_CMDSTS_ERR_GRP_CONFIG2,
219 IDXD_CMDSTS_ERR_GRP_CONFIG3,
220 IDXD_CMDSTS_ERR_GRP_CONFIG4,
221 /* enable wq errors */
222 IDXD_CMDSTS_ERR_DEV_NOTEN = 0x20,
223 IDXD_CMDSTS_ERR_WQ_ENABLED,
224 IDXD_CMDSTS_ERR_WQ_SIZE,
225 IDXD_CMDSTS_ERR_WQ_PRIOR,
226 IDXD_CMDSTS_ERR_WQ_MODE,
227 IDXD_CMDSTS_ERR_BOF_EN,
228 IDXD_CMDSTS_ERR_PASID_EN,
229 IDXD_CMDSTS_ERR_MAX_BATCH_SIZE,
230 IDXD_CMDSTS_ERR_MAX_XFER_SIZE,
231 /* disable device errors */
232 IDXD_CMDSTS_ERR_DIS_DEV_EN = 0x31,
233 /* disable WQ, drain WQ, abort WQ, reset WQ */
234 IDXD_CMDSTS_ERR_DEV_NOT_EN,
235 /* request interrupt handle */
236 IDXD_CMDSTS_ERR_INVAL_INT_IDX = 0x41,
237 IDXD_CMDSTS_ERR_NO_HANDLE,
240 #define IDXD_CMDCAP_OFFSET 0xb0
242 #define IDXD_SWERR_OFFSET 0xc0
243 #define IDXD_SWERR_VALID 0x00000001
244 #define IDXD_SWERR_OVERFLOW 0x00000002
245 #define IDXD_SWERR_ACK (IDXD_SWERR_VALID | IDXD_SWERR_OVERFLOW)
265 u64 invalid_flags:32;
290 u32 use_token_limit:1;
291 u32 tokens_reserved:8;
293 u32 tokens_allowed:8;
302 union group_flags flags;
316 u32 mode:1; /* shared or dedicated */
317 u32 bof:1; /* block on fault */
318 u32 wq_ats_disable:1;
327 u32 max_xfer_shift:5;
328 u32 max_batch_shift:4;
333 u16 occupancy_table_sel:1;
338 u16 occupancy_int_en:1;
354 #define WQCFG_PASID_IDX 2
355 #define WQCFG_OCCUP_IDX 6
357 #define WQCFG_OCCUP_MASK 0xffff
360 * This macro calculates the offset into the WQCFG register
361 * idxd - struct idxd *
363 * ofs - the index of the 32b dword for the config register
365 * The WQCFG register block is divided into groups per each wq. The n index
366 * allows us to move to the register group that's for that particular wq.
367 * Each register is 32bits. The ofs gives us the number of register to access.
369 #define WQCFG_OFFSET(_idxd_dev, n, ofs) \
371 typeof(_idxd_dev) __idxd_dev = (_idxd_dev); \
372 (__idxd_dev)->wqcfg_offset + (n) * (__idxd_dev)->wqcfg_size + sizeof(u32) * (ofs); \
375 #define WQCFG_STRIDES(_idxd_dev) ((_idxd_dev)->wqcfg_size / sizeof(u32))
377 #define GRPCFG_SIZE 64
378 #define GRPWQCFG_STRIDES 4
381 * This macro calculates the offset into the GRPCFG register
382 * idxd - struct idxd *
384 * ofs - the index of the 32b dword for the config register
386 * The WQCFG register block is divided into groups per each wq. The n index
387 * allows us to move to the register group that's for that particular wq.
388 * Each register is 32bits. The ofs gives us the number of register to access.
390 #define GRPWQCFG_OFFSET(idxd_dev, n, ofs) ((idxd_dev)->grpcfg_offset +\
391 (n) * GRPCFG_SIZE + sizeof(u64) * (ofs))
392 #define GRPENGCFG_OFFSET(idxd_dev, n) ((idxd_dev)->grpcfg_offset + (n) * GRPCFG_SIZE + 32)
393 #define GRPFLGCFG_OFFSET(idxd_dev, n) ((idxd_dev)->grpcfg_offset + (n) * GRPCFG_SIZE + 40)
395 /* Following is performance monitor registers */
396 #define IDXD_PERFCAP_OFFSET 0x0
399 u64 num_perf_counter:6;
402 u64 num_event_category:4;
403 u64 global_event_category:16;
406 u64 cap_per_counter:1;
407 u64 writeable_counter:1;
408 u64 counter_freeze:1;
409 u64 overflow_interrupt:1;
415 #define IDXD_EVNTCAP_OFFSET 0x80
427 u32 event_category:4;
434 #define IDXD_CNTRCAP_OFFSET 0x800
435 struct idxd_cntrcap {
444 struct idxd_event events[];
447 #define IDXD_PERFRST_OFFSET 0x10
450 u32 perfrst_config:1;
451 u32 perfrst_counter:1;
457 #define IDXD_OVFSTATUS_OFFSET 0x30
458 #define IDXD_PERFFRZ_OFFSET 0x20
459 #define IDXD_CNTRCFG_OFFSET 0x100
464 u64 global_freeze_ovf:1;
466 u64 event_category:4;
474 #define IDXD_FLTCFG_OFFSET 0x300
476 #define IDXD_CNTRDATA_OFFSET 0x200
477 union idxd_cntrdata {
479 u64 event_count_value;