1bfe1d560SDave Jiang /* SPDX-License-Identifier: GPL-2.0 */ 2bfe1d560SDave Jiang /* Copyright(c) 2019 Intel Corporation. All rights rsvd. */ 3bfe1d560SDave Jiang #ifndef _IDXD_REGISTERS_H_ 4bfe1d560SDave Jiang #define _IDXD_REGISTERS_H_ 5bfe1d560SDave Jiang 6bfe1d560SDave Jiang /* PCI Config */ 7bfe1d560SDave Jiang #define PCI_DEVICE_ID_INTEL_DSA_SPR0 0x0b25 8f25b4638SDave Jiang #define PCI_DEVICE_ID_INTEL_IAX_SPR0 0x0cfe 9bfe1d560SDave Jiang 10ade8a86bSDave Jiang #define DEVICE_VERSION_1 0x100 11ade8a86bSDave Jiang #define DEVICE_VERSION_2 0x200 12ade8a86bSDave Jiang 13bfe1d560SDave Jiang #define IDXD_MMIO_BAR 0 14bfe1d560SDave Jiang #define IDXD_WQ_BAR 2 158326be9fSDave Jiang #define IDXD_PORTAL_SIZE PAGE_SIZE 16bfe1d560SDave Jiang 17bfe1d560SDave Jiang /* MMIO Device BAR0 Registers */ 18bfe1d560SDave Jiang #define IDXD_VER_OFFSET 0x00 19bfe1d560SDave Jiang #define IDXD_VER_MAJOR_MASK 0xf0 20bfe1d560SDave Jiang #define IDXD_VER_MINOR_MASK 0x0f 21bfe1d560SDave Jiang #define GET_IDXD_VER_MAJOR(x) (((x) & IDXD_VER_MAJOR_MASK) >> 4) 22bfe1d560SDave Jiang #define GET_IDXD_VER_MINOR(x) ((x) & IDXD_VER_MINOR_MASK) 23bfe1d560SDave Jiang 24bfe1d560SDave Jiang union gen_cap_reg { 25bfe1d560SDave Jiang struct { 26bfe1d560SDave Jiang u64 block_on_fault:1; 27bfe1d560SDave Jiang u64 overlap_copy:1; 28bfe1d560SDave Jiang u64 cache_control_mem:1; 29bfe1d560SDave Jiang u64 cache_control_cache:1; 30eb15e715SDave Jiang u64 cmd_cap:1; 31bfe1d560SDave Jiang u64 rsvd:3; 32bfe1d560SDave Jiang u64 dest_readback:1; 33bfe1d560SDave Jiang u64 drain_readback:1; 34bfe1d560SDave Jiang u64 rsvd2:6; 35bfe1d560SDave Jiang u64 max_xfer_shift:5; 36bfe1d560SDave Jiang u64 max_batch_shift:4; 37bfe1d560SDave Jiang u64 max_ims_mult:6; 38bfe1d560SDave Jiang u64 config_en:1; 39c5b64b68SDave Jiang u64 rsvd3:32; 40bfe1d560SDave Jiang }; 41bfe1d560SDave Jiang u64 bits; 42bfe1d560SDave Jiang } __packed; 43bfe1d560SDave Jiang #define IDXD_GENCAP_OFFSET 0x10 44bfe1d560SDave Jiang 45bfe1d560SDave Jiang union wq_cap_reg { 46bfe1d560SDave Jiang struct { 47bfe1d560SDave Jiang u64 total_wq_size:16; 48bfe1d560SDave Jiang u64 num_wqs:8; 49484f910eSDave Jiang u64 wqcfg_size:4; 50484f910eSDave Jiang u64 rsvd:20; 51bfe1d560SDave Jiang u64 shared_mode:1; 52bfe1d560SDave Jiang u64 dedicated_mode:1; 5392de5fa2SDave Jiang u64 wq_ats_support:1; 54bfe1d560SDave Jiang u64 priority:1; 55bfe1d560SDave Jiang u64 occupancy:1; 56bfe1d560SDave Jiang u64 occupancy_int:1; 57b0325aefSDave Jiang u64 op_config:1; 58b0325aefSDave Jiang u64 rsvd3:9; 59bfe1d560SDave Jiang }; 60bfe1d560SDave Jiang u64 bits; 61bfe1d560SDave Jiang } __packed; 62bfe1d560SDave Jiang #define IDXD_WQCAP_OFFSET 0x20 63484f910eSDave Jiang #define IDXD_WQCFG_MIN 5 64bfe1d560SDave Jiang 65bfe1d560SDave Jiang union group_cap_reg { 66bfe1d560SDave Jiang struct { 67bfe1d560SDave Jiang u64 num_groups:8; 687ed6f1b8SDave Jiang u64 total_rdbufs:8; /* formerly total_tokens */ 697ed6f1b8SDave Jiang u64 rdbuf_ctrl:1; /* formerly token_en */ 707ed6f1b8SDave Jiang u64 rdbuf_limit:1; /* formerly token_limit */ 71*1f273752SDave Jiang u64 progress_limit:1; /* descriptor and batch descriptor */ 72*1f273752SDave Jiang u64 rsvd:45; 73bfe1d560SDave Jiang }; 74bfe1d560SDave Jiang u64 bits; 75bfe1d560SDave Jiang } __packed; 76bfe1d560SDave Jiang #define IDXD_GRPCAP_OFFSET 0x30 77bfe1d560SDave Jiang 78bfe1d560SDave Jiang union engine_cap_reg { 79bfe1d560SDave Jiang struct { 80bfe1d560SDave Jiang u64 num_engines:8; 81bfe1d560SDave Jiang u64 rsvd:56; 82bfe1d560SDave Jiang }; 83bfe1d560SDave Jiang u64 bits; 84bfe1d560SDave Jiang } __packed; 85bfe1d560SDave Jiang 86bfe1d560SDave Jiang #define IDXD_ENGCAP_OFFSET 0x38 87bfe1d560SDave Jiang 88bfe1d560SDave Jiang #define IDXD_OPCAP_NOOP 0x0001 89bfe1d560SDave Jiang #define IDXD_OPCAP_BATCH 0x0002 90bfe1d560SDave Jiang #define IDXD_OPCAP_MEMMOVE 0x0008 91bfe1d560SDave Jiang struct opcap { 92bfe1d560SDave Jiang u64 bits[4]; 93bfe1d560SDave Jiang }; 94bfe1d560SDave Jiang 95a8563a33SDave Jiang #define IDXD_MAX_OPCAP_BITS 256U 96a8563a33SDave Jiang 97bfe1d560SDave Jiang #define IDXD_OPCAP_OFFSET 0x40 98bfe1d560SDave Jiang 99bfe1d560SDave Jiang #define IDXD_TABLE_OFFSET 0x60 100bfe1d560SDave Jiang union offsets_reg { 101bfe1d560SDave Jiang struct { 102bfe1d560SDave Jiang u64 grpcfg:16; 103bfe1d560SDave Jiang u64 wqcfg:16; 104bfe1d560SDave Jiang u64 msix_perm:16; 105bfe1d560SDave Jiang u64 ims:16; 106bfe1d560SDave Jiang u64 perfmon:16; 107bfe1d560SDave Jiang u64 rsvd:48; 108bfe1d560SDave Jiang }; 109bfe1d560SDave Jiang u64 bits[2]; 110bfe1d560SDave Jiang } __packed; 111bfe1d560SDave Jiang 1122f8417a9SDave Jiang #define IDXD_TABLE_MULT 0x100 1132f8417a9SDave Jiang 114bfe1d560SDave Jiang #define IDXD_GENCFG_OFFSET 0x80 115bfe1d560SDave Jiang union gencfg_reg { 116bfe1d560SDave Jiang struct { 1177ed6f1b8SDave Jiang u32 rdbuf_limit:8; 118bfe1d560SDave Jiang u32 rsvd:4; 119bfe1d560SDave Jiang u32 user_int_en:1; 120bfe1d560SDave Jiang u32 rsvd2:19; 121bfe1d560SDave Jiang }; 122bfe1d560SDave Jiang u32 bits; 123bfe1d560SDave Jiang } __packed; 124bfe1d560SDave Jiang 125bfe1d560SDave Jiang #define IDXD_GENCTRL_OFFSET 0x88 126bfe1d560SDave Jiang union genctrl_reg { 127bfe1d560SDave Jiang struct { 128bfe1d560SDave Jiang u32 softerr_int_en:1; 1295b0c68c4SDave Jiang u32 halt_int_en:1; 1305b0c68c4SDave Jiang u32 rsvd:30; 131bfe1d560SDave Jiang }; 132bfe1d560SDave Jiang u32 bits; 133bfe1d560SDave Jiang } __packed; 134bfe1d560SDave Jiang 135bfe1d560SDave Jiang #define IDXD_GENSTATS_OFFSET 0x90 136bfe1d560SDave Jiang union gensts_reg { 137bfe1d560SDave Jiang struct { 138bfe1d560SDave Jiang u32 state:2; 139bfe1d560SDave Jiang u32 reset_type:2; 140bfe1d560SDave Jiang u32 rsvd:28; 141bfe1d560SDave Jiang }; 142bfe1d560SDave Jiang u32 bits; 143bfe1d560SDave Jiang } __packed; 144bfe1d560SDave Jiang 145bfe1d560SDave Jiang enum idxd_device_status_state { 146bfe1d560SDave Jiang IDXD_DEVICE_STATE_DISABLED = 0, 147bfe1d560SDave Jiang IDXD_DEVICE_STATE_ENABLED, 148bfe1d560SDave Jiang IDXD_DEVICE_STATE_DRAIN, 149bfe1d560SDave Jiang IDXD_DEVICE_STATE_HALT, 150bfe1d560SDave Jiang }; 151bfe1d560SDave Jiang 152bfe1d560SDave Jiang enum idxd_device_reset_type { 153bfe1d560SDave Jiang IDXD_DEVICE_RESET_SOFTWARE = 0, 154bfe1d560SDave Jiang IDXD_DEVICE_RESET_FLR, 155bfe1d560SDave Jiang IDXD_DEVICE_RESET_WARM, 156bfe1d560SDave Jiang IDXD_DEVICE_RESET_COLD, 157bfe1d560SDave Jiang }; 158bfe1d560SDave Jiang 159bfe1d560SDave Jiang #define IDXD_INTCAUSE_OFFSET 0x98 160bfe1d560SDave Jiang #define IDXD_INTC_ERR 0x01 161bfe1d560SDave Jiang #define IDXD_INTC_CMD 0x02 162bfe1d560SDave Jiang #define IDXD_INTC_OCCUPY 0x04 163bfe1d560SDave Jiang #define IDXD_INTC_PERFMON_OVFL 0x08 16488d97ea8SDave Jiang #define IDXD_INTC_HALT_STATE 0x10 16556fc39f5SDave Jiang #define IDXD_INTC_INT_HANDLE_REVOKED 0x80000000 166bfe1d560SDave Jiang 167bfe1d560SDave Jiang #define IDXD_CMD_OFFSET 0xa0 168bfe1d560SDave Jiang union idxd_command_reg { 169bfe1d560SDave Jiang struct { 170bfe1d560SDave Jiang u32 operand:20; 171bfe1d560SDave Jiang u32 cmd:5; 172bfe1d560SDave Jiang u32 rsvd:6; 173bfe1d560SDave Jiang u32 int_req:1; 174bfe1d560SDave Jiang }; 175bfe1d560SDave Jiang u32 bits; 176bfe1d560SDave Jiang } __packed; 177bfe1d560SDave Jiang 178bfe1d560SDave Jiang enum idxd_cmd { 179bfe1d560SDave Jiang IDXD_CMD_ENABLE_DEVICE = 1, 180bfe1d560SDave Jiang IDXD_CMD_DISABLE_DEVICE, 181bfe1d560SDave Jiang IDXD_CMD_DRAIN_ALL, 182bfe1d560SDave Jiang IDXD_CMD_ABORT_ALL, 183bfe1d560SDave Jiang IDXD_CMD_RESET_DEVICE, 184bfe1d560SDave Jiang IDXD_CMD_ENABLE_WQ, 185bfe1d560SDave Jiang IDXD_CMD_DISABLE_WQ, 186bfe1d560SDave Jiang IDXD_CMD_DRAIN_WQ, 187bfe1d560SDave Jiang IDXD_CMD_ABORT_WQ, 188bfe1d560SDave Jiang IDXD_CMD_RESET_WQ, 189bfe1d560SDave Jiang IDXD_CMD_DRAIN_PASID, 190bfe1d560SDave Jiang IDXD_CMD_ABORT_PASID, 191bfe1d560SDave Jiang IDXD_CMD_REQUEST_INT_HANDLE, 192eb15e715SDave Jiang IDXD_CMD_RELEASE_INT_HANDLE, 193bfe1d560SDave Jiang }; 194bfe1d560SDave Jiang 195eb15e715SDave Jiang #define CMD_INT_HANDLE_IMS 0x10000 196eb15e715SDave Jiang 197bfe1d560SDave Jiang #define IDXD_CMDSTS_OFFSET 0xa8 198bfe1d560SDave Jiang union cmdsts_reg { 199bfe1d560SDave Jiang struct { 200bfe1d560SDave Jiang u8 err; 201bfe1d560SDave Jiang u16 result; 202bfe1d560SDave Jiang u8 rsvd:7; 203bfe1d560SDave Jiang u8 active:1; 204bfe1d560SDave Jiang }; 205bfe1d560SDave Jiang u32 bits; 206bfe1d560SDave Jiang } __packed; 207bfe1d560SDave Jiang #define IDXD_CMDSTS_ACTIVE 0x80000000 208eb15e715SDave Jiang #define IDXD_CMDSTS_ERR_MASK 0xff 209eb15e715SDave Jiang #define IDXD_CMDSTS_RES_SHIFT 8 210bfe1d560SDave Jiang 211bfe1d560SDave Jiang enum idxd_cmdsts_err { 212bfe1d560SDave Jiang IDXD_CMDSTS_SUCCESS = 0, 213bfe1d560SDave Jiang IDXD_CMDSTS_INVAL_CMD, 214bfe1d560SDave Jiang IDXD_CMDSTS_INVAL_WQIDX, 215bfe1d560SDave Jiang IDXD_CMDSTS_HW_ERR, 216bfe1d560SDave Jiang /* enable device errors */ 217bfe1d560SDave Jiang IDXD_CMDSTS_ERR_DEV_ENABLED = 0x10, 218bfe1d560SDave Jiang IDXD_CMDSTS_ERR_CONFIG, 219bfe1d560SDave Jiang IDXD_CMDSTS_ERR_BUSMASTER_EN, 220bfe1d560SDave Jiang IDXD_CMDSTS_ERR_PASID_INVAL, 221bfe1d560SDave Jiang IDXD_CMDSTS_ERR_WQ_SIZE_ERANGE, 222bfe1d560SDave Jiang IDXD_CMDSTS_ERR_GRP_CONFIG, 223bfe1d560SDave Jiang IDXD_CMDSTS_ERR_GRP_CONFIG2, 224bfe1d560SDave Jiang IDXD_CMDSTS_ERR_GRP_CONFIG3, 225bfe1d560SDave Jiang IDXD_CMDSTS_ERR_GRP_CONFIG4, 226bfe1d560SDave Jiang /* enable wq errors */ 227bfe1d560SDave Jiang IDXD_CMDSTS_ERR_DEV_NOTEN = 0x20, 228bfe1d560SDave Jiang IDXD_CMDSTS_ERR_WQ_ENABLED, 229bfe1d560SDave Jiang IDXD_CMDSTS_ERR_WQ_SIZE, 230bfe1d560SDave Jiang IDXD_CMDSTS_ERR_WQ_PRIOR, 231bfe1d560SDave Jiang IDXD_CMDSTS_ERR_WQ_MODE, 232bfe1d560SDave Jiang IDXD_CMDSTS_ERR_BOF_EN, 233bfe1d560SDave Jiang IDXD_CMDSTS_ERR_PASID_EN, 234bfe1d560SDave Jiang IDXD_CMDSTS_ERR_MAX_BATCH_SIZE, 235bfe1d560SDave Jiang IDXD_CMDSTS_ERR_MAX_XFER_SIZE, 236bfe1d560SDave Jiang /* disable device errors */ 237bfe1d560SDave Jiang IDXD_CMDSTS_ERR_DIS_DEV_EN = 0x31, 238bfe1d560SDave Jiang /* disable WQ, drain WQ, abort WQ, reset WQ */ 239bfe1d560SDave Jiang IDXD_CMDSTS_ERR_DEV_NOT_EN, 240bfe1d560SDave Jiang /* request interrupt handle */ 241bfe1d560SDave Jiang IDXD_CMDSTS_ERR_INVAL_INT_IDX = 0x41, 242bfe1d560SDave Jiang IDXD_CMDSTS_ERR_NO_HANDLE, 243bfe1d560SDave Jiang }; 244bfe1d560SDave Jiang 245eb15e715SDave Jiang #define IDXD_CMDCAP_OFFSET 0xb0 246eb15e715SDave Jiang 247bfe1d560SDave Jiang #define IDXD_SWERR_OFFSET 0xc0 248bfe1d560SDave Jiang #define IDXD_SWERR_VALID 0x00000001 249bfe1d560SDave Jiang #define IDXD_SWERR_OVERFLOW 0x00000002 250bfe1d560SDave Jiang #define IDXD_SWERR_ACK (IDXD_SWERR_VALID | IDXD_SWERR_OVERFLOW) 251bfe1d560SDave Jiang union sw_err_reg { 252bfe1d560SDave Jiang struct { 253bfe1d560SDave Jiang u64 valid:1; 254bfe1d560SDave Jiang u64 overflow:1; 255bfe1d560SDave Jiang u64 desc_valid:1; 256bfe1d560SDave Jiang u64 wq_idx_valid:1; 257bfe1d560SDave Jiang u64 batch:1; 258bfe1d560SDave Jiang u64 fault_rw:1; 259bfe1d560SDave Jiang u64 priv:1; 260bfe1d560SDave Jiang u64 rsvd:1; 261bfe1d560SDave Jiang u64 error:8; 262bfe1d560SDave Jiang u64 wq_idx:8; 263bfe1d560SDave Jiang u64 rsvd2:8; 264bfe1d560SDave Jiang u64 operation:8; 265bfe1d560SDave Jiang u64 pasid:20; 266bfe1d560SDave Jiang u64 rsvd3:4; 267bfe1d560SDave Jiang 268bfe1d560SDave Jiang u64 batch_idx:16; 269bfe1d560SDave Jiang u64 rsvd4:16; 270bfe1d560SDave Jiang u64 invalid_flags:32; 271bfe1d560SDave Jiang 272bfe1d560SDave Jiang u64 fault_addr; 273bfe1d560SDave Jiang 274bfe1d560SDave Jiang u64 rsvd5; 275bfe1d560SDave Jiang }; 276bfe1d560SDave Jiang u64 bits[4]; 277bfe1d560SDave Jiang } __packed; 278bfe1d560SDave Jiang 279bfe1d560SDave Jiang union msix_perm { 280bfe1d560SDave Jiang struct { 281bfe1d560SDave Jiang u32 rsvd:2; 282bfe1d560SDave Jiang u32 ignore:1; 283bfe1d560SDave Jiang u32 pasid_en:1; 284bfe1d560SDave Jiang u32 rsvd2:8; 285bfe1d560SDave Jiang u32 pasid:20; 286bfe1d560SDave Jiang }; 287bfe1d560SDave Jiang u32 bits; 288bfe1d560SDave Jiang } __packed; 289bfe1d560SDave Jiang 290bfe1d560SDave Jiang union group_flags { 291bfe1d560SDave Jiang struct { 292*1f273752SDave Jiang u64 tc_a:3; 293*1f273752SDave Jiang u64 tc_b:3; 294*1f273752SDave Jiang u64 rsvd:1; 295*1f273752SDave Jiang u64 use_rdbuf_limit:1; 296*1f273752SDave Jiang u64 rdbufs_reserved:8; 297*1f273752SDave Jiang u64 rsvd2:4; 298*1f273752SDave Jiang u64 rdbufs_allowed:8; 299*1f273752SDave Jiang u64 rsvd3:4; 300*1f273752SDave Jiang u64 desc_progress_limit:2; 301*1f273752SDave Jiang u64 rsvd4:30; 302bfe1d560SDave Jiang }; 303*1f273752SDave Jiang u64 bits; 304bfe1d560SDave Jiang } __packed; 305bfe1d560SDave Jiang 306bfe1d560SDave Jiang struct grpcfg { 307bfe1d560SDave Jiang u64 wqs[4]; 308bfe1d560SDave Jiang u64 engines; 309bfe1d560SDave Jiang union group_flags flags; 310bfe1d560SDave Jiang } __packed; 311bfe1d560SDave Jiang 312bfe1d560SDave Jiang union wqcfg { 313bfe1d560SDave Jiang struct { 314bfe1d560SDave Jiang /* bytes 0-3 */ 315bfe1d560SDave Jiang u16 wq_size; 316bfe1d560SDave Jiang u16 rsvd; 317bfe1d560SDave Jiang 318bfe1d560SDave Jiang /* bytes 4-7 */ 319bfe1d560SDave Jiang u16 wq_thresh; 320bfe1d560SDave Jiang u16 rsvd1; 321bfe1d560SDave Jiang 322bfe1d560SDave Jiang /* bytes 8-11 */ 323bfe1d560SDave Jiang u32 mode:1; /* shared or dedicated */ 324bfe1d560SDave Jiang u32 bof:1; /* block on fault */ 32592de5fa2SDave Jiang u32 wq_ats_disable:1; 32692de5fa2SDave Jiang u32 rsvd2:1; 327bfe1d560SDave Jiang u32 priority:4; 328bfe1d560SDave Jiang u32 pasid:20; 329bfe1d560SDave Jiang u32 pasid_en:1; 330bfe1d560SDave Jiang u32 priv:1; 331bfe1d560SDave Jiang u32 rsvd3:2; 332bfe1d560SDave Jiang 333bfe1d560SDave Jiang /* bytes 12-15 */ 334bfe1d560SDave Jiang u32 max_xfer_shift:5; 335bfe1d560SDave Jiang u32 max_batch_shift:4; 336bfe1d560SDave Jiang u32 rsvd4:23; 337bfe1d560SDave Jiang 338bfe1d560SDave Jiang /* bytes 16-19 */ 339bfe1d560SDave Jiang u16 occupancy_inth; 340bfe1d560SDave Jiang u16 occupancy_table_sel:1; 341bfe1d560SDave Jiang u16 rsvd5:15; 342bfe1d560SDave Jiang 343bfe1d560SDave Jiang /* bytes 20-23 */ 344bfe1d560SDave Jiang u16 occupancy_limit; 345bfe1d560SDave Jiang u16 occupancy_int_en:1; 346bfe1d560SDave Jiang u16 rsvd6:15; 347bfe1d560SDave Jiang 348bfe1d560SDave Jiang /* bytes 24-27 */ 349bfe1d560SDave Jiang u16 occupancy; 350bfe1d560SDave Jiang u16 occupancy_int:1; 351bfe1d560SDave Jiang u16 rsvd7:12; 352bfe1d560SDave Jiang u16 mode_support:1; 353bfe1d560SDave Jiang u16 wq_state:2; 354bfe1d560SDave Jiang 355bfe1d560SDave Jiang /* bytes 28-31 */ 356bfe1d560SDave Jiang u32 rsvd8; 357b0325aefSDave Jiang 358b0325aefSDave Jiang /* bytes 32-63 */ 359b0325aefSDave Jiang u64 op_config[4]; 360bfe1d560SDave Jiang }; 361b0325aefSDave Jiang u32 bits[16]; 362bfe1d560SDave Jiang } __packed; 363484f910eSDave Jiang 3648e50d392SDave Jiang #define WQCFG_PASID_IDX 2 3653157dd0aSDave Jiang #define WQCFG_PRIVL_IDX 2 366e753a64bSDave Jiang #define WQCFG_OCCUP_IDX 6 367e753a64bSDave Jiang 368e753a64bSDave Jiang #define WQCFG_OCCUP_MASK 0xffff 3698e50d392SDave Jiang 370484f910eSDave Jiang /* 371484f910eSDave Jiang * This macro calculates the offset into the WQCFG register 372484f910eSDave Jiang * idxd - struct idxd * 373484f910eSDave Jiang * n - wq id 374484f910eSDave Jiang * ofs - the index of the 32b dword for the config register 375484f910eSDave Jiang * 376484f910eSDave Jiang * The WQCFG register block is divided into groups per each wq. The n index 377484f910eSDave Jiang * allows us to move to the register group that's for that particular wq. 378484f910eSDave Jiang * Each register is 32bits. The ofs gives us the number of register to access. 379484f910eSDave Jiang */ 380484f910eSDave Jiang #define WQCFG_OFFSET(_idxd_dev, n, ofs) \ 381484f910eSDave Jiang ({\ 382484f910eSDave Jiang typeof(_idxd_dev) __idxd_dev = (_idxd_dev); \ 383484f910eSDave Jiang (__idxd_dev)->wqcfg_offset + (n) * (__idxd_dev)->wqcfg_size + sizeof(u32) * (ofs); \ 384484f910eSDave Jiang }) 385484f910eSDave Jiang 386484f910eSDave Jiang #define WQCFG_STRIDES(_idxd_dev) ((_idxd_dev)->wqcfg_size / sizeof(u32)) 387484f910eSDave Jiang 3885a712701SDave Jiang #define GRPCFG_SIZE 64 3895a712701SDave Jiang #define GRPWQCFG_STRIDES 4 3905a712701SDave Jiang 3915a712701SDave Jiang /* 3925a712701SDave Jiang * This macro calculates the offset into the GRPCFG register 3935a712701SDave Jiang * idxd - struct idxd * 3945a712701SDave Jiang * n - wq id 3955a712701SDave Jiang * ofs - the index of the 32b dword for the config register 3965a712701SDave Jiang * 3975a712701SDave Jiang * The WQCFG register block is divided into groups per each wq. The n index 3985a712701SDave Jiang * allows us to move to the register group that's for that particular wq. 3995a712701SDave Jiang * Each register is 32bits. The ofs gives us the number of register to access. 4005a712701SDave Jiang */ 4015a712701SDave Jiang #define GRPWQCFG_OFFSET(idxd_dev, n, ofs) ((idxd_dev)->grpcfg_offset +\ 4025a712701SDave Jiang (n) * GRPCFG_SIZE + sizeof(u64) * (ofs)) 4035a712701SDave Jiang #define GRPENGCFG_OFFSET(idxd_dev, n) ((idxd_dev)->grpcfg_offset + (n) * GRPCFG_SIZE + 32) 4045a712701SDave Jiang #define GRPFLGCFG_OFFSET(idxd_dev, n) ((idxd_dev)->grpcfg_offset + (n) * GRPCFG_SIZE + 40) 4055a712701SDave Jiang 40681dd4d4dSTom Zanussi /* Following is performance monitor registers */ 40781dd4d4dSTom Zanussi #define IDXD_PERFCAP_OFFSET 0x0 40881dd4d4dSTom Zanussi union idxd_perfcap { 40981dd4d4dSTom Zanussi struct { 41081dd4d4dSTom Zanussi u64 num_perf_counter:6; 41181dd4d4dSTom Zanussi u64 rsvd1:2; 41281dd4d4dSTom Zanussi u64 counter_width:8; 41381dd4d4dSTom Zanussi u64 num_event_category:4; 41481dd4d4dSTom Zanussi u64 global_event_category:16; 41581dd4d4dSTom Zanussi u64 filter:8; 41681dd4d4dSTom Zanussi u64 rsvd2:8; 41781dd4d4dSTom Zanussi u64 cap_per_counter:1; 41881dd4d4dSTom Zanussi u64 writeable_counter:1; 41981dd4d4dSTom Zanussi u64 counter_freeze:1; 42081dd4d4dSTom Zanussi u64 overflow_interrupt:1; 42181dd4d4dSTom Zanussi u64 rsvd3:8; 42281dd4d4dSTom Zanussi }; 42381dd4d4dSTom Zanussi u64 bits; 42481dd4d4dSTom Zanussi } __packed; 42581dd4d4dSTom Zanussi 42681dd4d4dSTom Zanussi #define IDXD_EVNTCAP_OFFSET 0x80 42781dd4d4dSTom Zanussi union idxd_evntcap { 42881dd4d4dSTom Zanussi struct { 42981dd4d4dSTom Zanussi u64 events:28; 43081dd4d4dSTom Zanussi u64 rsvd:36; 43181dd4d4dSTom Zanussi }; 43281dd4d4dSTom Zanussi u64 bits; 43381dd4d4dSTom Zanussi } __packed; 43481dd4d4dSTom Zanussi 43581dd4d4dSTom Zanussi struct idxd_event { 43681dd4d4dSTom Zanussi union { 43781dd4d4dSTom Zanussi struct { 43881dd4d4dSTom Zanussi u32 event_category:4; 43981dd4d4dSTom Zanussi u32 events:28; 44081dd4d4dSTom Zanussi }; 44181dd4d4dSTom Zanussi u32 val; 44281dd4d4dSTom Zanussi }; 44381dd4d4dSTom Zanussi } __packed; 44481dd4d4dSTom Zanussi 44581dd4d4dSTom Zanussi #define IDXD_CNTRCAP_OFFSET 0x800 44681dd4d4dSTom Zanussi struct idxd_cntrcap { 44781dd4d4dSTom Zanussi union { 44881dd4d4dSTom Zanussi struct { 44981dd4d4dSTom Zanussi u32 counter_width:8; 45081dd4d4dSTom Zanussi u32 rsvd:20; 45181dd4d4dSTom Zanussi u32 num_events:4; 45281dd4d4dSTom Zanussi }; 45381dd4d4dSTom Zanussi u32 val; 45481dd4d4dSTom Zanussi }; 45581dd4d4dSTom Zanussi struct idxd_event events[]; 45681dd4d4dSTom Zanussi } __packed; 45781dd4d4dSTom Zanussi 45881dd4d4dSTom Zanussi #define IDXD_PERFRST_OFFSET 0x10 45981dd4d4dSTom Zanussi union idxd_perfrst { 46081dd4d4dSTom Zanussi struct { 46181dd4d4dSTom Zanussi u32 perfrst_config:1; 46281dd4d4dSTom Zanussi u32 perfrst_counter:1; 46381dd4d4dSTom Zanussi u32 rsvd:30; 46481dd4d4dSTom Zanussi }; 46581dd4d4dSTom Zanussi u32 val; 46681dd4d4dSTom Zanussi } __packed; 46781dd4d4dSTom Zanussi 46881dd4d4dSTom Zanussi #define IDXD_OVFSTATUS_OFFSET 0x30 46981dd4d4dSTom Zanussi #define IDXD_PERFFRZ_OFFSET 0x20 47081dd4d4dSTom Zanussi #define IDXD_CNTRCFG_OFFSET 0x100 47181dd4d4dSTom Zanussi union idxd_cntrcfg { 47281dd4d4dSTom Zanussi struct { 47381dd4d4dSTom Zanussi u64 enable:1; 47481dd4d4dSTom Zanussi u64 interrupt_ovf:1; 47581dd4d4dSTom Zanussi u64 global_freeze_ovf:1; 47681dd4d4dSTom Zanussi u64 rsvd1:5; 47781dd4d4dSTom Zanussi u64 event_category:4; 47881dd4d4dSTom Zanussi u64 rsvd2:20; 47981dd4d4dSTom Zanussi u64 events:28; 48081dd4d4dSTom Zanussi u64 rsvd3:4; 48181dd4d4dSTom Zanussi }; 48281dd4d4dSTom Zanussi u64 val; 48381dd4d4dSTom Zanussi } __packed; 48481dd4d4dSTom Zanussi 48581dd4d4dSTom Zanussi #define IDXD_FLTCFG_OFFSET 0x300 48681dd4d4dSTom Zanussi 48781dd4d4dSTom Zanussi #define IDXD_CNTRDATA_OFFSET 0x200 48881dd4d4dSTom Zanussi union idxd_cntrdata { 48981dd4d4dSTom Zanussi struct { 49081dd4d4dSTom Zanussi u64 event_count_value; 49181dd4d4dSTom Zanussi }; 49281dd4d4dSTom Zanussi u64 val; 49381dd4d4dSTom Zanussi } __packed; 49481dd4d4dSTom Zanussi 49581dd4d4dSTom Zanussi union event_cfg { 49681dd4d4dSTom Zanussi struct { 49781dd4d4dSTom Zanussi u64 event_cat:4; 49881dd4d4dSTom Zanussi u64 event_enc:28; 49981dd4d4dSTom Zanussi }; 50081dd4d4dSTom Zanussi u64 val; 50181dd4d4dSTom Zanussi } __packed; 50281dd4d4dSTom Zanussi 50381dd4d4dSTom Zanussi union filter_cfg { 50481dd4d4dSTom Zanussi struct { 50581dd4d4dSTom Zanussi u64 wq:32; 50681dd4d4dSTom Zanussi u64 tc:8; 50781dd4d4dSTom Zanussi u64 pg_sz:4; 50881dd4d4dSTom Zanussi u64 xfer_sz:8; 50981dd4d4dSTom Zanussi u64 eng:8; 51081dd4d4dSTom Zanussi }; 51181dd4d4dSTom Zanussi u64 val; 51281dd4d4dSTom Zanussi } __packed; 51381dd4d4dSTom Zanussi 514bfe1d560SDave Jiang #endif 515