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 IDXD_MMIO_BAR 0
12 #define IDXD_PORTAL_SIZE PAGE_SIZE
14 /* MMIO Device BAR0 Registers */
15 #define IDXD_VER_OFFSET 0x00
16 #define IDXD_VER_MAJOR_MASK 0xf0
17 #define IDXD_VER_MINOR_MASK 0x0f
18 #define GET_IDXD_VER_MAJOR(x) (((x) & IDXD_VER_MAJOR_MASK) >> 4)
19 #define GET_IDXD_VER_MINOR(x) ((x) & IDXD_VER_MINOR_MASK)
25 u64 cache_control_mem
:1;
26 u64 cache_control_cache
:1;
33 u64 max_batch_shift
:4;
36 u64 max_descs_per_engine
:8;
41 #define IDXD_GENCAP_OFFSET 0x10
59 #define IDXD_WQCAP_OFFSET 0x20
60 #define IDXD_WQCFG_MIN 5
72 #define IDXD_GRPCAP_OFFSET 0x30
74 union engine_cap_reg
{
82 #define IDXD_ENGCAP_OFFSET 0x38
84 #define IDXD_OPCAP_NOOP 0x0001
85 #define IDXD_OPCAP_BATCH 0x0002
86 #define IDXD_OPCAP_MEMMOVE 0x0008
91 #define IDXD_OPCAP_OFFSET 0x40
93 #define IDXD_TABLE_OFFSET 0x60
106 #define IDXD_TABLE_MULT 0x100
108 #define IDXD_GENCFG_OFFSET 0x80
119 #define IDXD_GENCTRL_OFFSET 0x88
122 u32 softerr_int_en
:1;
128 #define IDXD_GENSTATS_OFFSET 0x90
138 enum idxd_device_status_state
{
139 IDXD_DEVICE_STATE_DISABLED
= 0,
140 IDXD_DEVICE_STATE_ENABLED
,
141 IDXD_DEVICE_STATE_DRAIN
,
142 IDXD_DEVICE_STATE_HALT
,
145 enum idxd_device_reset_type
{
146 IDXD_DEVICE_RESET_SOFTWARE
= 0,
147 IDXD_DEVICE_RESET_FLR
,
148 IDXD_DEVICE_RESET_WARM
,
149 IDXD_DEVICE_RESET_COLD
,
152 #define IDXD_INTCAUSE_OFFSET 0x98
153 #define IDXD_INTC_ERR 0x01
154 #define IDXD_INTC_CMD 0x02
155 #define IDXD_INTC_OCCUPY 0x04
156 #define IDXD_INTC_PERFMON_OVFL 0x08
158 #define IDXD_CMD_OFFSET 0xa0
159 union idxd_command_reg
{
170 IDXD_CMD_ENABLE_DEVICE
= 1,
171 IDXD_CMD_DISABLE_DEVICE
,
174 IDXD_CMD_RESET_DEVICE
,
180 IDXD_CMD_DRAIN_PASID
,
181 IDXD_CMD_ABORT_PASID
,
182 IDXD_CMD_REQUEST_INT_HANDLE
,
185 #define IDXD_CMDSTS_OFFSET 0xa8
195 #define IDXD_CMDSTS_ACTIVE 0x80000000
197 enum idxd_cmdsts_err
{
198 IDXD_CMDSTS_SUCCESS
= 0,
199 IDXD_CMDSTS_INVAL_CMD
,
200 IDXD_CMDSTS_INVAL_WQIDX
,
202 /* enable device errors */
203 IDXD_CMDSTS_ERR_DEV_ENABLED
= 0x10,
204 IDXD_CMDSTS_ERR_CONFIG
,
205 IDXD_CMDSTS_ERR_BUSMASTER_EN
,
206 IDXD_CMDSTS_ERR_PASID_INVAL
,
207 IDXD_CMDSTS_ERR_WQ_SIZE_ERANGE
,
208 IDXD_CMDSTS_ERR_GRP_CONFIG
,
209 IDXD_CMDSTS_ERR_GRP_CONFIG2
,
210 IDXD_CMDSTS_ERR_GRP_CONFIG3
,
211 IDXD_CMDSTS_ERR_GRP_CONFIG4
,
212 /* enable wq errors */
213 IDXD_CMDSTS_ERR_DEV_NOTEN
= 0x20,
214 IDXD_CMDSTS_ERR_WQ_ENABLED
,
215 IDXD_CMDSTS_ERR_WQ_SIZE
,
216 IDXD_CMDSTS_ERR_WQ_PRIOR
,
217 IDXD_CMDSTS_ERR_WQ_MODE
,
218 IDXD_CMDSTS_ERR_BOF_EN
,
219 IDXD_CMDSTS_ERR_PASID_EN
,
220 IDXD_CMDSTS_ERR_MAX_BATCH_SIZE
,
221 IDXD_CMDSTS_ERR_MAX_XFER_SIZE
,
222 /* disable device errors */
223 IDXD_CMDSTS_ERR_DIS_DEV_EN
= 0x31,
224 /* disable WQ, drain WQ, abort WQ, reset WQ */
225 IDXD_CMDSTS_ERR_DEV_NOT_EN
,
226 /* request interrupt handle */
227 IDXD_CMDSTS_ERR_INVAL_INT_IDX
= 0x41,
228 IDXD_CMDSTS_ERR_NO_HANDLE
,
231 #define IDXD_SWERR_OFFSET 0xc0
232 #define IDXD_SWERR_VALID 0x00000001
233 #define IDXD_SWERR_OVERFLOW 0x00000002
234 #define IDXD_SWERR_ACK (IDXD_SWERR_VALID | IDXD_SWERR_OVERFLOW)
254 u64 invalid_flags
:32;
279 u32 use_token_limit
:1;
280 u32 tokens_reserved
:8;
282 u32 tokens_allowed
:8;
291 union group_flags flags
;
305 u32 mode
:1; /* shared or dedicated */
306 u32 bof
:1; /* block on fault */
307 u32 wq_ats_disable
:1;
316 u32 max_xfer_shift
:5;
317 u32 max_batch_shift
:4;
322 u16 occupancy_table_sel
:1;
327 u16 occupancy_int_en
:1;
343 #define WQCFG_PASID_IDX 2
346 * This macro calculates the offset into the WQCFG register
347 * idxd - struct idxd *
349 * ofs - the index of the 32b dword for the config register
351 * The WQCFG register block is divided into groups per each wq. The n index
352 * allows us to move to the register group that's for that particular wq.
353 * Each register is 32bits. The ofs gives us the number of register to access.
355 #define WQCFG_OFFSET(_idxd_dev, n, ofs) \
357 typeof(_idxd_dev) __idxd_dev = (_idxd_dev); \
358 (__idxd_dev)->wqcfg_offset + (n) * (__idxd_dev)->wqcfg_size + sizeof(u32) * (ofs); \
361 #define WQCFG_STRIDES(_idxd_dev) ((_idxd_dev)->wqcfg_size / sizeof(u32))
363 #define GRPCFG_SIZE 64
364 #define GRPWQCFG_STRIDES 4
367 * This macro calculates the offset into the GRPCFG register
368 * idxd - struct idxd *
370 * ofs - the index of the 32b dword for the config register
372 * The WQCFG register block is divided into groups per each wq. The n index
373 * allows us to move to the register group that's for that particular wq.
374 * Each register is 32bits. The ofs gives us the number of register to access.
376 #define GRPWQCFG_OFFSET(idxd_dev, n, ofs) ((idxd_dev)->grpcfg_offset +\
377 (n) * GRPCFG_SIZE + sizeof(u64) * (ofs))
378 #define GRPENGCFG_OFFSET(idxd_dev, n) ((idxd_dev)->grpcfg_offset + (n) * GRPCFG_SIZE + 32)
379 #define GRPFLGCFG_OFFSET(idxd_dev, n) ((idxd_dev)->grpcfg_offset + (n) * GRPCFG_SIZE + 40)