#ifndef _DEV_PCI_QATREG_H_
#define _DEV_PCI_QATREG_H_
#define __BIT(__n) \
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : \
((uintmax_t)1 << (uintmax_t)((__n) & (NBBY * sizeof(uintmax_t) - 1))))
#define __BITS(__m, __n) \
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
#define __LOWEST_SET_BIT(__mask) ((((__mask) - 1) & (__mask)) ^ (__mask))
#define __SHIFTOUT(__x, __mask) (((__x) & (__mask)) / __LOWEST_SET_BIT(__mask))
#define __SHIFTIN(__x, __mask) ((__x) * __LOWEST_SET_BIT(__mask))
#define MAX_NUM_AE 0x10
#define MAX_NUM_ACCEL 6
#define MAX_AE 0x18
#define MAX_AE_CTX 8
#define MAX_ARB 4
#define MAX_USTORE_PER_SEG 0x8000
#define MAX_USTORE MAX_USTORE_PER_SEG
#define MAX_AE_PER_ACCEL 4
#define MAX_BANK_PER_ACCEL 16
#define MAX_RING_PER_BANK 16
#define MAX_XFER_REG 128
#define MAX_GPR_REG 128
#define MAX_NN_REG 128
#define MAX_LMEM_REG 1024
#define MAX_INP_STATE 16
#define MAX_CAM_REG 16
#define MAX_FIFO_QWADDR 160
#define MAX_EXEC_INST 100
#define UWORD_CPYBUF_SIZE 1024
#define INVLD_UWORD 0xffffffffffull
#define AEV2_PACKED_UWORD_BYTES 6
#define UWORD_MASK 0xbffffffffffull
#define AE_ALL_CTX 0xff
#define NO_PCI_REG (-1)
#define NO_REG_OFFSET 0
#define MAX_BARS 3
#define FUSECTL_REG 0x40
#define FUSECTL_MASK __BIT(31)
#define LEGFUSE_REG 0x4c
#define LEGFUSE_ACCEL_MASK_CIPHER_SLICE __BIT(0)
#define LEGFUSE_ACCEL_MASK_AUTH_SLICE __BIT(1)
#define LEGFUSE_ACCEL_MASK_PKE_SLICE __BIT(2)
#define LEGFUSE_ACCEL_MASK_COMPRESS_SLICE __BIT(3)
#define LEGFUSE_ACCEL_MASK_LZS_SLICE __BIT(4)
#define LEGFUSE_ACCEL_MASK_EIA3_SLICE __BIT(5)
#define LEGFUSE_ACCEL_MASK_SHA3_SLICE __BIT(6)
#define ETR_MAX_RINGS_PER_BANK 16
#define ETR_RING_CONFIG 0x0000
#define ETR_RING_LBASE 0x0040
#define ETR_RING_UBASE 0x0080
#define ETR_RING_HEAD_OFFSET 0x00C0
#define ETR_RING_TAIL_OFFSET 0x0100
#define ETR_RING_STAT 0x0140
#define ETR_UO_STAT 0x0148
#define ETR_E_STAT 0x014C
#define ETR_NE_STAT 0x0150
#define ETR_NF_STAT 0x0154
#define ETR_F_STAT 0x0158
#define ETR_C_STAT 0x015C
#define ETR_INT_EN 0x016C
#define ETR_INT_REG 0x0170
#define ETR_INT_SRCSEL 0x0174
#define ETR_INT_SRCSEL_2 0x0178
#define ETR_INT_COL_EN 0x017C
#define ETR_INT_COL_CTL 0x0180
#define ETR_AP_NF_MASK 0x2000
#define ETR_AP_NF_DEST 0x2020
#define ETR_AP_NE_MASK 0x2040
#define ETR_AP_NE_DEST 0x2060
#define ETR_AP_DELAY 0x2080
#define ARB_OFFSET 0x30000
#define ARB_REG_SIZE 0x4
#define ARB_WTR_SIZE 0x20
#define ARB_REG_SLOT 0x1000
#define ARB_WTR_OFFSET 0x010
#define ARB_RO_EN_OFFSET 0x090
#define ARB_WRK_2_SER_MAP_OFFSET 0x180
#define ARB_RINGSRVARBEN_OFFSET 0x19c
#define ETR_RING_CONFIG_LATE_HEAD_POINTER_MODE __BIT(31)
#define ETR_RING_CONFIG_NEAR_FULL_WM __BITS(14, 10)
#define ETR_RING_CONFIG_NEAR_EMPTY_WM __BITS(9, 5)
#define ETR_RING_CONFIG_RING_SIZE __BITS(4, 0)
#define ETR_RING_CONFIG_NEAR_WM_0 0x00
#define ETR_RING_CONFIG_NEAR_WM_4 0x01
#define ETR_RING_CONFIG_NEAR_WM_8 0x02
#define ETR_RING_CONFIG_NEAR_WM_16 0x03
#define ETR_RING_CONFIG_NEAR_WM_32 0x04
#define ETR_RING_CONFIG_NEAR_WM_64 0x05
#define ETR_RING_CONFIG_NEAR_WM_128 0x06
#define ETR_RING_CONFIG_NEAR_WM_256 0x07
#define ETR_RING_CONFIG_NEAR_WM_512 0x08
#define ETR_RING_CONFIG_NEAR_WM_1K 0x09
#define ETR_RING_CONFIG_NEAR_WM_2K 0x0A
#define ETR_RING_CONFIG_NEAR_WM_4K 0x0B
#define ETR_RING_CONFIG_NEAR_WM_8K 0x0C
#define ETR_RING_CONFIG_NEAR_WM_16K 0x0D
#define ETR_RING_CONFIG_NEAR_WM_32K 0x0E
#define ETR_RING_CONFIG_NEAR_WM_64K 0x0F
#define ETR_RING_CONFIG_NEAR_WM_128K 0x10
#define ETR_RING_CONFIG_NEAR_WM_256K 0x11
#define ETR_RING_CONFIG_NEAR_WM_512K 0x12
#define ETR_RING_CONFIG_NEAR_WM_1M 0x13
#define ETR_RING_CONFIG_NEAR_WM_2M 0x14
#define ETR_RING_CONFIG_NEAR_WM_4M 0x15
#define ETR_RING_CONFIG_SIZE_64 0x00
#define ETR_RING_CONFIG_SIZE_128 0x01
#define ETR_RING_CONFIG_SIZE_256 0x02
#define ETR_RING_CONFIG_SIZE_512 0x03
#define ETR_RING_CONFIG_SIZE_1K 0x04
#define ETR_RING_CONFIG_SIZE_2K 0x05
#define ETR_RING_CONFIG_SIZE_4K 0x06
#define ETR_RING_CONFIG_SIZE_8K 0x07
#define ETR_RING_CONFIG_SIZE_16K 0x08
#define ETR_RING_CONFIG_SIZE_32K 0x09
#define ETR_RING_CONFIG_SIZE_64K 0x0A
#define ETR_RING_CONFIG_SIZE_128K 0x0B
#define ETR_RING_CONFIG_SIZE_256K 0x0C
#define ETR_RING_CONFIG_SIZE_512K 0x0D
#define ETR_RING_CONFIG_SIZE_1M 0x0E
#define ETR_RING_CONFIG_SIZE_2M 0x0F
#define ETR_RING_CONFIG_SIZE_4M 0x10
#define ETR_RING_CONFIG_BUILD(size) \
(__SHIFTIN(ETR_RING_CONFIG_NEAR_WM_0, \
ETR_RING_CONFIG_NEAR_FULL_WM) | \
__SHIFTIN(ETR_RING_CONFIG_NEAR_WM_0, \
ETR_RING_CONFIG_NEAR_EMPTY_WM) | \
__SHIFTIN((size), ETR_RING_CONFIG_RING_SIZE))
#define ETR_RING_CONFIG_BUILD_RESP(size, wm_nf, wm_ne) \
(__SHIFTIN((wm_nf), ETR_RING_CONFIG_NEAR_FULL_WM) | \
__SHIFTIN((wm_ne), ETR_RING_CONFIG_NEAR_EMPTY_WM) | \
__SHIFTIN((size), ETR_RING_CONFIG_RING_SIZE))
#define ETR_RING_BASE_BUILD(addr, size) \
(((addr) >> 6) & (0xFFFFFFFFFFFFFFFFULL << (size)))
#define ETR_INT_REG_CLEAR_MASK 0xffff
#define ETR_INT_SRCSEL_MASK 0x44444444UL
#define ETR_INT_SRCSEL_NEXT_OFFSET 4
#define ETR_RINGS_PER_INT_SRCSEL 8
#define ETR_INT_COL_CTL_ENABLE __BIT(31)
#define ETR_AP_NF_MASK_INIT 0xAAAAAAAA
#define ETR_AP_NE_MASK_INIT 0x55555555
#define ETR_AP_DEST_ENABLE __BIT(7)
#define ETR_AP_DEST_AE __BITS(6, 2)
#define ETR_AP_DEST_MAILBOX __BITS(1, 0)
#define ETR_AP_BANK_OFFSET 4
#define ETR_MAX_RINGS_PER_AP_BANK 32
#define ETR_MAX_MAILBOX_PER_ACCELERATOR 4
#define ETR_MAX_AE_PER_MAILBOX 4
#define ETR_RING_AP_BANK_NUMBER(ring) ((ring) >> 5)
#define ETR_RING_AP_MAILBOX_NUMBER(ring) \
(ETR_RING_AP_BANK_NUMBER(ring) % ETR_MAX_MAILBOX_PER_ACCELERATOR)
#define ETR_RING_NUMBER_IN_AP_BANK(ring) \
((ring) % ETR_MAX_RINGS_PER_AP_BANK)
#define ETR_RING_EMPTY_ENTRY_SIG (0x7F7F7F7F)
#define FCU_CTRL 0x8c0
#define FCU_CTRL_CMD_NOOP 0
#define FCU_CTRL_CMD_AUTH 1
#define FCU_CTRL_CMD_LOAD 2
#define FCU_CTRL_CMD_START 3
#define FCU_CTRL_AE __BITS(8, 31)
#define FCU_STATUS 0x8c4
#define FCU_STATUS_STS __BITS(0, 2)
#define FCU_STATUS_STS_NO 0
#define FCU_STATUS_STS_VERI_DONE 1
#define FCU_STATUS_STS_LOAD_DONE 2
#define FCU_STATUS_STS_VERI_FAIL 3
#define FCU_STATUS_STS_LOAD_FAIL 4
#define FCU_STATUS_STS_BUSY 5
#define FCU_STATUS_AUTHFWLD __BIT(8)
#define FCU_STATUS_DONE __BIT(9)
#define FCU_STATUS_LOADED_AE __BITS(22, 31)
#define FCU_STATUS1 0x8c8
#define FCU_DRAM_ADDR_LO 0x8cc
#define FCU_DRAM_ADDR_HI 0x8d0
#define FCU_RAMBASE_ADDR_HI 0x8d4
#define FCU_RAMBASE_ADDR_LO 0x8d8
#define FW_AUTH_WAIT_PERIOD 10
#define FW_AUTH_MAX_RETRY 300
#define CAP_GLOBAL_CTL_BASE 0xa00
#define CAP_GLOBAL_CTL_MISC CAP_GLOBAL_CTL_BASE + 0x04
#define CAP_GLOBAL_CTL_MISC_TIMESTAMP_EN __BIT(7)
#define CAP_GLOBAL_CTL_RESET CAP_GLOBAL_CTL_BASE + 0x0c
#define CAP_GLOBAL_CTL_RESET_MASK __BITS(31, 26)
#define CAP_GLOBAL_CTL_RESET_ACCEL_MASK __BITS(25, 20)
#define CAP_GLOBAL_CTL_RESET_AE_MASK __BITS(19, 0)
#define CAP_GLOBAL_CTL_CLK_EN CAP_GLOBAL_CTL_BASE + 0x50
#define CAP_GLOBAL_CTL_CLK_EN_ACCEL_MASK __BITS(25, 20)
#define CAP_GLOBAL_CTL_CLK_EN_AE_MASK __BITS(19, 0)
#define UPC_MASK 0x1ffff
#define USTORE_SIZE QAT_16K
#define AE_LOCAL_AE_MASK __BITS(31, 12)
#define AE_LOCAL_CSR_MASK __BITS(9, 0)
#define USTORE_ADDRESS 0x000
#define USTORE_ADDRESS_ECS __BIT(31)
#define USTORE_ECC_BIT_0 44
#define USTORE_ECC_BIT_1 45
#define USTORE_ECC_BIT_2 46
#define USTORE_ECC_BIT_3 47
#define USTORE_ECC_BIT_4 48
#define USTORE_ECC_BIT_5 49
#define USTORE_ECC_BIT_6 50
#define USTORE_DATA_LOWER 0x004
#define USTORE_DATA_UPPER 0x008
#define USTORE_ERROR_STATUS 0x00c
#define ALU_OUT 0x010
#define CTX_ARB_CNTL 0x014
#define CTX_ARB_CNTL_INIT 0x00000000
#define CTX_ENABLES 0x018
#define CTX_ENABLES_INIT 0
#define CTX_ENABLES_INUSE_CONTEXTS __BIT(31)
#define CTX_ENABLES_CNTL_STORE_PARITY_ERROR __BIT(29)
#define CTX_ENABLES_CNTL_STORE_PARITY_ENABLE __BIT(28)
#define CTX_ENABLES_BREAKPOINT __BIT(27)
#define CTX_ENABLES_PAR_ERR __BIT(25)
#define CTX_ENABLES_NN_MODE __BIT(20)
#define CTX_ENABLES_NN_RING_EMPTY __BIT(18)
#define CTX_ENABLES_LMADDR_1_GLOBAL __BIT(17)
#define CTX_ENABLES_LMADDR_0_GLOBAL __BIT(16)
#define CTX_ENABLES_ENABLE __BITS(15,8)
#define CTX_ENABLES_IGNORE_W1C_MASK \
(~(CTX_ENABLES_PAR_ERR | \
CTX_ENABLES_BREAKPOINT | \
CTX_ENABLES_CNTL_STORE_PARITY_ERROR))
#define CYCLES_FROM_READY2EXE 8
#define CC_ENABLE 0x01c
#define CC_ENABLE_INIT 0x2000
#define CSR_CTX_POINTER 0x020
#define CSR_CTX_POINTER_CONTEXT __BITS(2,0)
#define REG_ERROR_STATUS 0x030
#define CTX_STS_INDIRECT 0x040
#define CTX_STS_INDIRECT_UPC_INIT 0x00000000
#define ACTIVE_CTX_STATUS 0x044
#define ACTIVE_CTX_STATUS_ABO __BIT(31)
#define ACTIVE_CTX_STATUS_ACNO __BITS(0, 2)
#define CTX_SIG_EVENTS_INDIRECT 0x048
#define CTX_SIG_EVENTS_INDIRECT_INIT 0x00000001
#define CTX_SIG_EVENTS_ACTIVE 0x04c
#define CTX_WAKEUP_EVENTS_INDIRECT 0x050
#define CTX_WAKEUP_EVENTS_INDIRECT_VOLUNTARY 0x00000001
#define CTX_WAKEUP_EVENTS_INDIRECT_SLEEP 0x00010000
#define CTX_WAKEUP_EVENTS_INDIRECT_INIT 0x00000001
#define CTX_WAKEUP_EVENTS_ACTIVE 0x054
#define CTX_FUTURE_COUNT_INDIRECT 0x058
#define CTX_FUTURE_COUNT_ACTIVE 0x05c
#define LM_ADDR_0_INDIRECT 0x060
#define LM_ADDR_0_ACTIVE 0x064
#define LM_ADDR_1_INDIRECT 0x068
#define LM_ADDR_1_ACTIVE 0x06c
#define BYTE_INDEX 0x070
#define INDIRECT_LM_ADDR_0_BYTE_INDEX 0x0e0
#define ACTIVE_LM_ADDR_0_BYTE_INDEX 0x0e4
#define INDIRECT_LM_ADDR_1_BYTE_INDEX 0x0e8
#define ACTIVE_LM_ADDR_1_BYTE_INDEX 0x0ec
#define T_INDEX_BYTE_INDEX 0x0f4
#define T_INDEX 0x074
#define FUTURE_COUNT_SIGNAL_INDIRECT 0x078
#define FUTURE_COUNT_SIGNAL_ACTIVE 0x07c
#define NN_PUT 0x080
#define NN_GET 0x084
#define TIMESTAMP_LOW 0x0c0
#define TIMESTAMP_HIGH 0x0c4
#define NEXT_NEIGHBOR_SIGNAL 0x100
#define PREV_NEIGHBOR_SIGNAL 0x104
#define SAME_AE_SIGNAL 0x108
#define CRC_REMAINDER 0x140
#define PROFILE_COUNT 0x144
#define PSEUDO_RANDOM_NUMBER 0x148
#define SIGNATURE_ENABLE 0x150
#define AE_MISC_CONTROL 0x160
#define AE_MISC_CONTROL_PARITY_ENABLE __BIT(24)
#define AE_MISC_CONTROL_FORCE_BAD_PARITY __BIT(23)
#define AE_MISC_CONTROL_ONE_CTX_RELOAD __BIT(22)
#define AE_MISC_CONTROL_CS_RELOAD __BITS(21, 20)
#define AE_MISC_CONTROL_SHARE_CS __BIT(2)
#define USTORE_ADDRESS1 0x158
#define LOCAL_CSR_STATUS 0x180
#define LOCAL_CSR_STATUS_STATUS 0x1
#define NULL_CSR 0x3fc
#define AE_XFER_AE_MASK __BITS(31, 12)
#define AE_XFER_CSR_MASK __BITS(9, 2)
#define AEREG_BAD_REGADDR 0xffff
#define SSMWDT(i) ((i) * 0x4000 + 0x54)
#define SSMWDTPKE(i) ((i) * 0x4000 + 0x58)
#define INTSTATSSM(i) ((i) * 0x4000 + 0x04)
#define INTSTATSSM_SHANGERR __BIT(13)
#define PPERR(i) ((i) * 0x4000 + 0x08)
#define PPERRID(i) ((i) * 0x4000 + 0x0C)
#define CERRSSMSH(i) ((i) * 0x4000 + 0x10)
#define UERRSSMSH(i) ((i) * 0x4000 + 0x18)
#define UERRSSMSHAD(i) ((i) * 0x4000 + 0x1C)
#define SLICEHANGSTATUS(i) ((i) * 0x4000 + 0x4C)
#define SLICE_HANG_AUTH0_MASK __BIT(0)
#define SLICE_HANG_AUTH1_MASK __BIT(1)
#define SLICE_HANG_CPHR0_MASK __BIT(4)
#define SLICE_HANG_CPHR1_MASK __BIT(5)
#define SLICE_HANG_CMP0_MASK __BIT(8)
#define SLICE_HANG_CMP1_MASK __BIT(9)
#define SLICE_HANG_XLT0_MASK __BIT(12)
#define SLICE_HANG_XLT1_MASK __BIT(13)
#define SLICE_HANG_MMP0_MASK __BIT(16)
#define SLICE_HANG_MMP1_MASK __BIT(17)
#define SLICE_HANG_MMP2_MASK __BIT(18)
#define SLICE_HANG_MMP3_MASK __BIT(19)
#define SLICE_HANG_MMP4_MASK __BIT(20)
#define SHINTMASKSSM(i) ((i) * 0x4000 + 0x1018)
#define ENABLE_SLICE_HANG 0x000000
#define MAX_MMP (5)
#define MMP_BASE(i) ((i) * 0x1000 % 0x3800)
#define CERRSSMMMP(i, n) ((i) * 0x4000 + MMP_BASE(n) + 0x380)
#define UERRSSMMMP(i, n) ((i) * 0x4000 + MMP_BASE(n) + 0x388)
#define UERRSSMMMPAD(i, n) ((i) * 0x4000 + MMP_BASE(n) + 0x38C)
#define CPP_CFC_ERR_STATUS (0x30000 + 0xC04)
#define CPP_CFC_ERR_PPID (0x30000 + 0xC08)
#define ERRSOU0 (0x3A000 + 0x00)
#define ERRSOU1 (0x3A000 + 0x04)
#define ERRSOU2 (0x3A000 + 0x08)
#define ERRSOU3 (0x3A000 + 0x0C)
#define ERRSOU4 (0x3A000 + 0xD0)
#define ERRSOU5 (0x3A000 + 0xD8)
#define ERRMSK0 (0x3A000 + 0x10)
#define ERRMSK1 (0x3A000 + 0x14)
#define ERRMSK2 (0x3A000 + 0x18)
#define ERRMSK3 (0x3A000 + 0x1C)
#define ERRMSK4 (0x3A000 + 0xD4)
#define ERRMSK5 (0x3A000 + 0xDC)
#define EMSK3_CPM0_MASK __BIT(2)
#define EMSK3_CPM1_MASK __BIT(3)
#define EMSK5_CPM2_MASK __BIT(16)
#define EMSK5_CPM3_MASK __BIT(17)
#define EMSK5_CPM4_MASK __BIT(18)
#define RICPPINTSTS (0x3A000 + 0x114)
#define RIERRPUSHID (0x3A000 + 0x118)
#define RIERRPULLID (0x3A000 + 0x11C)
#define TICPPINTSTS (0x3A400 + 0x13C)
#define TIERRPUSHID (0x3A400 + 0x140)
#define TIERRPULLID (0x3A400 + 0x144)
#define SECRAMUERR (0x3AC00 + 0x04)
#define SECRAMUERRAD (0x3AC00 + 0x0C)
#define CPPMEMTGTERR (0x3AC00 + 0x10)
#define ERRPPID (0x3AC00 + 0x14)
#define ADMINMSGUR 0x3a574
#define ADMINMSGLR 0x3a578
#define MAILBOX_BASE 0x20970
#define MAILBOX_STRIDE 0x1000
#define ADMINMSG_LEN 32
static const uint8_t mailbox_const_tab[1024] __aligned(1024) = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x02, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x13, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76,
0x54, 0x32, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, 0x45, 0x23, 0x01, 0xef, 0xcd, 0xab,
0x89, 0x98, 0xba, 0xdc, 0xfe, 0x10, 0x32, 0x54, 0x76, 0xc3, 0xd2, 0xe1, 0xf0,
0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x05, 0x9e,
0xd8, 0x36, 0x7c, 0xd5, 0x07, 0x30, 0x70, 0xdd, 0x17, 0xf7, 0x0e, 0x59, 0x39,
0xff, 0xc0, 0x0b, 0x31, 0x68, 0x58, 0x15, 0x11, 0x64, 0xf9, 0x8f, 0xa7, 0xbe,
0xfa, 0x4f, 0xa4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6a, 0x09, 0xe6, 0x67, 0xbb, 0x67, 0xae,
0x85, 0x3c, 0x6e, 0xf3, 0x72, 0xa5, 0x4f, 0xf5, 0x3a, 0x51, 0x0e, 0x52, 0x7f,
0x9b, 0x05, 0x68, 0x8c, 0x1f, 0x83, 0xd9, 0xab, 0x5b, 0xe0, 0xcd, 0x19, 0x05,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xcb, 0xbb, 0x9d, 0x5d, 0xc1, 0x05, 0x9e, 0xd8, 0x62, 0x9a, 0x29,
0x2a, 0x36, 0x7c, 0xd5, 0x07, 0x91, 0x59, 0x01, 0x5a, 0x30, 0x70, 0xdd, 0x17,
0x15, 0x2f, 0xec, 0xd8, 0xf7, 0x0e, 0x59, 0x39, 0x67, 0x33, 0x26, 0x67, 0xff,
0xc0, 0x0b, 0x31, 0x8e, 0xb4, 0x4a, 0x87, 0x68, 0x58, 0x15, 0x11, 0xdb, 0x0c,
0x2e, 0x0d, 0x64, 0xf9, 0x8f, 0xa7, 0x47, 0xb5, 0x48, 0x1d, 0xbe, 0xfa, 0x4f,
0xa4, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x6a, 0x09, 0xe6, 0x67, 0xf3, 0xbc, 0xc9, 0x08, 0xbb,
0x67, 0xae, 0x85, 0x84, 0xca, 0xa7, 0x3b, 0x3c, 0x6e, 0xf3, 0x72, 0xfe, 0x94,
0xf8, 0x2b, 0xa5, 0x4f, 0xf5, 0x3a, 0x5f, 0x1d, 0x36, 0xf1, 0x51, 0x0e, 0x52,
0x7f, 0xad, 0xe6, 0x82, 0xd1, 0x9b, 0x05, 0x68, 0x8c, 0x2b, 0x3e, 0x6c, 0x1f,
0x1f, 0x83, 0xd9, 0xab, 0xfb, 0x41, 0xbd, 0x6b, 0x5b, 0xe0, 0xcd, 0x19, 0x13,
0x7e, 0x21, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static const uint64_t ae_clear_gprs_inst[] = {
0x0F0000C0000ull,
0x0F000000380ull,
0x0D805000011ull,
0x0FC082C0300ull,
0x0F0000C0300ull,
0x0F0000C0300ull,
0x0F0000C0300ull,
0x0F0000C0300ull,
0x0A0643C0000ull,
0x0BAC0000301ull,
0x0D802000101ull,
0x0F0000C0001ull,
0x0FC066C0001ull,
0x0F0000C0300ull,
0x0F0000C0300ull,
0x0F0000C0300ull,
0x0F000400300ull,
0x0A0610C0000ull,
0x0BAC0000301ull,
0x0D804400101ull,
0x0A0580C0000ull,
0x0A0581C0000ull,
0x0A0582C0000ull,
0x0A0583C0000ull,
0x0A0584C0000ull,
0x0A0585C0000ull,
0x0A0586C0000ull,
0x0A0587C0000ull,
0x0A0588C0000ull,
0x0A0589C0000ull,
0x0A058AC0000ull,
0x0A058BC0000ull,
0x0A058CC0000ull,
0x0A058DC0000ull,
0x0A058EC0000ull,
0x0A058FC0000ull,
0x0A05C0C0000ull,
0x0A05C1C0000ull,
0x0A05C2C0000ull,
0x0A05C3C0000ull,
0x0A05C4C0000ull,
0x0A05C5C0000ull,
0x0A05C6C0000ull,
0x0A05C7C0000ull,
0x0A05C8C0000ull,
0x0A05C9C0000ull,
0x0A05CAC0000ull,
0x0A05CBC0000ull,
0x0A05CCC0000ull,
0x0A05CDC0000ull,
0x0A05CEC0000ull,
0x0A05CFC0000ull,
0x0A0400C0000ull,
0x0B0400C0000ull,
0x0A0401C0000ull,
0x0B0401C0000ull,
0x0A0402C0000ull,
0x0B0402C0000ull,
0x0A0403C0000ull,
0x0B0403C0000ull,
0x0A0404C0000ull,
0x0B0404C0000ull,
0x0A0405C0000ull,
0x0B0405C0000ull,
0x0A0406C0000ull,
0x0B0406C0000ull,
0x0A0407C0000ull,
0x0B0407C0000ull,
0x0A0408C0000ull,
0x0B0408C0000ull,
0x0A0409C0000ull,
0x0B0409C0000ull,
0x0A040AC0000ull,
0x0B040AC0000ull,
0x0A040BC0000ull,
0x0B040BC0000ull,
0x0A040CC0000ull,
0x0B040CC0000ull,
0x0A040DC0000ull,
0x0B040DC0000ull,
0x0A040EC0000ull,
0x0B040EC0000ull,
0x0A040FC0000ull,
0x0B040FC0000ull,
0x0D81581C010ull,
0x0E000010000ull,
0x0E000010000ull,
};
static const uint64_t ae_inst_4b[] = {
0x0F0400C0000ull,
0x0F4400C0000ull,
0x0F040000300ull,
0x0F440000300ull,
0x0FC066C0000ull,
0x0F0000C0300ull,
0x0F0000C0300ull,
0x0F0000C0300ull,
0x0A021000000ull,
};
static const uint64_t ae_inst_1b[] = {
0x0F0400C0000ull,
0x0F4400C0000ull,
0x0F040000300ull,
0x0F440000300ull,
0x0FC066C0000ull,
0x0F0000C0300ull,
0x0F0000C0300ull,
0x0F0000C0300ull,
0x0A000180000ull,
0x09080000200ull,
0x08180280201ull,
0x08080280102ull,
0x0BA00100002ull,
};
static const uint64_t ae_inst_2b[] = {
0x0F0400C0000ull,
0x0F4400C0000ull,
0x0F040000300ull,
0x0F440000300ull,
0x0FC066C0000ull,
0x0F0000C0300ull,
0x0F0000C0300ull,
0x0F0000C0300ull,
0x0A000180000ull,
0x09100000200ull,
0x08100280201ull,
0x08100280102ull,
0x0BA00100002ull,
};
static const uint64_t ae_inst_3b[] = {
0x0F0400C0000ull,
0x0F4400C0000ull,
0x0F040000300ull,
0x0F440000300ull,
0x0FC066C0000ull,
0x0F0000C0300ull,
0x0F0000C0300ull,
0x0F0000C0300ull,
0x0A000180000ull,
0x09180000200ull,
0x08080280201ull,
0x08180280102ull,
0x0BA00100002ull,
};
#define INSERT_IMMED_GPRA_CONST(inst, const_val) \
inst = (inst & 0xFFFF00C03FFull) | \
((((const_val) << 12) & 0x0FF00000ull) | \
(((const_val) << 10) & 0x0003FC00ull))
#define INSERT_IMMED_GPRB_CONST(inst, const_val) \
inst = (inst & 0xFFFF00FFF00ull) | \
((((const_val) << 12) & 0x0FF00000ull) | \
(((const_val) << 0) & 0x000000FFull))
enum aereg_type {
AEREG_NO_DEST,
AEREG_GPA_REL,
AEREG_GPA_ABS,
AEREG_GPB_REL,
AEREG_GPB_ABS,
AEREG_SR_REL,
AEREG_SR_RD_REL,
AEREG_SR_WR_REL,
AEREG_SR_ABS,
AEREG_SR_RD_ABS,
AEREG_SR_WR_ABS,
AEREG_SR0_SPILL,
AEREG_SR1_SPILL,
AEREG_SR2_SPILL,
AEREG_SR3_SPILL,
AEREG_SR0_MEM_ADDR,
AEREG_SR1_MEM_ADDR,
AEREG_SR2_MEM_ADDR,
AEREG_SR3_MEM_ADDR,
AEREG_DR_REL,
AEREG_DR_RD_REL,
AEREG_DR_WR_REL,
AEREG_DR_ABS,
AEREG_DR_RD_ABS,
AEREG_DR_WR_ABS,
AEREG_DR_MEM_ADDR,
AEREG_LMEM,
AEREG_LMEM0,
AEREG_LMEM1,
AEREG_LMEM_SPILL,
AEREG_LMEM_ADDR,
AEREG_NEIGH_REL,
AEREG_NEIGH_INDX,
AEREG_SIG_REL,
AEREG_SIG_INDX,
AEREG_SIG_DOUBLE,
AEREG_SIG_SINGLE,
AEREG_SCRATCH_MEM_ADDR,
AEREG_UMEM0,
AEREG_UMEM1,
AEREG_UMEM_SPILL,
AEREG_UMEM_ADDR,
AEREG_DR1_MEM_ADDR,
AEREG_SR0_IMPORTED,
AEREG_SR1_IMPORTED,
AEREG_SR2_IMPORTED,
AEREG_SR3_IMPORTED,
AEREG_DR_IMPORTED,
AEREG_DR1_IMPORTED,
AEREG_SCRATCH_IMPORTED,
AEREG_XFER_RD_ABS,
AEREG_XFER_WR_ABS,
AEREG_CONST_VALUE,
AEREG_ADDR_TAKEN,
AEREG_OPTIMIZED_AWAY,
AEREG_SHRAM_ADDR,
AEREG_SHRAM1_ADDR,
AEREG_SHRAM2_ADDR,
AEREG_SHRAM3_ADDR,
AEREG_SHRAM4_ADDR,
AEREG_SHRAM5_ADDR,
AEREG_ANY = 0xffff
};
#define AEREG_SR_INDX AEREG_SR_ABS
#define AEREG_DR_INDX AEREG_DR_ABS
#define AEREG_NEIGH_ABS AEREG_NEIGH_INDX
#define QAT_2K 0x0800
#define QAT_4K 0x1000
#define QAT_6K 0x1800
#define QAT_8K 0x2000
#define QAT_16K 0x4000
#define MOF_OBJ_ID_LEN 8
#define MOF_FID 0x00666f6d
#define MOF_MIN_VER 0x1
#define MOF_MAJ_VER 0x0
#define SYM_OBJS "SYM_OBJS"
#define UOF_OBJS "UOF_OBJS"
#define SUOF_OBJS "SUF_OBJS"
#define SUOF_IMAG "SUF_IMAG"
#define UOF_STRT "UOF_STRT"
#define UOF_GTID "UOF_GTID"
#define UOF_IMAG "UOF_IMAG"
#define UOF_IMEM "UOF_IMEM"
#define UOF_MSEG "UOF_MSEG"
#define CRC_POLY 0x1021
#define CRC_WIDTH 16
#define CRC_BITMASK(x) (1L << (x))
#define CRC_WIDTHMASK(width) ((((1L<<(width-1))-1L)<<1)|1L)
struct mof_file_hdr {
u_int mfh_fid;
u_int mfh_csum;
char mfh_min_ver;
char mfh_maj_ver;
u_short mfh_reserved;
u_short mfh_max_chunks;
u_short mfh_num_chunks;
};
struct mof_file_chunk_hdr {
char mfch_id[MOF_OBJ_ID_LEN];
uint64_t mfch_offset;
uint64_t mfch_size;
};
struct mof_uof_hdr {
u_short muh_max_chunks;
u_short muh_num_chunks;
u_int muh_reserved;
};
struct mof_uof_chunk_hdr {
char much_id[MOF_OBJ_ID_LEN];
uint64_t much_offset;
uint64_t much_size;
u_int much_name;
u_int much_reserved;
};
#define UOF_MAX_NUM_OF_AE 16
#define UOF_OBJ_ID_LEN 8
#define UOF_FIELD_POS_SIZE 12
#define MIN_UOF_SIZE 24
#define UOF_FID 0xc6c2
#define UOF_MIN_VER 0x11
#define UOF_MAJ_VER 0x4
struct uof_file_hdr {
u_short ufh_id;
u_short ufh_reserved1;
char ufh_min_ver;
char ufh_maj_ver;
u_short ufh_reserved2;
u_short ufh_max_chunks;
u_short ufh_num_chunks;
};
struct uof_file_chunk_hdr {
char ufch_id[UOF_OBJ_ID_LEN];
u_int ufch_csum;
u_int ufch_offset;
u_int ufch_size;
};
struct uof_obj_hdr {
u_int uoh_cpu_type;
u_short uoh_min_cpu_ver;
u_short uoh_max_cpu_ver;
short uoh_max_chunks;
short uoh_num_chunks;
u_int uoh_reserved1;
u_int uoh_reserved2;
};
struct uof_chunk_hdr {
char uch_id[UOF_OBJ_ID_LEN];
u_int uch_offset;
u_int uch_size;
};
struct uof_str_tab {
u_int ust_table_len;
u_int ust_reserved;
uint64_t ust_strings;
};
#define AE_MODE_RELOAD_CTX_SHARED __BIT(12)
#define AE_MODE_SHARED_USTORE __BIT(11)
#define AE_MODE_LMEM1 __BIT(9)
#define AE_MODE_LMEM0 __BIT(8)
#define AE_MODE_NN_MODE __BITS(7, 4)
#define AE_MODE_CTX_MODE __BITS(3, 0)
#define AE_MODE_NN_MODE_NEIGH 0
#define AE_MODE_NN_MODE_SELF 1
#define AE_MODE_NN_MODE_DONTCARE 0xff
struct uof_image {
u_int ui_name;
u_int ui_ae_assigned;
u_int ui_ctx_assigned;
u_int ui_cpu_type;
u_int ui_entry_address;
u_int ui_fill_pattern[2];
u_int ui_reloadable_size;
u_char ui_sensitivity;
u_char ui_reserved;
u_short ui_ae_mode;
u_short ui_max_ver;
u_short ui_min_ver;
u_short ui_image_attrib;
u_short ui_reserved2;
u_short ui_num_page_regions;
u_short ui_num_pages;
u_int ui_reg_tab;
u_int ui_init_reg_sym_tab;
u_int ui_sbreak_tab;
u_int ui_app_metadata;
};
struct uof_obj_table {
u_int uot_nentries;
};
struct uof_ae_reg {
u_int uar_name;
u_int uar_vis_name;
u_short uar_type;
u_short uar_addr;
u_short uar_access_mode;
u_char uar_visible;
u_char uar_reserved1;
u_short uar_ref_count;
u_short uar_reserved2;
u_int uar_xoid;
};
enum uof_value_kind {
UNDEF_VAL,
CHAR_VAL,
SHORT_VAL,
INT_VAL,
STR_VAL,
STRTAB_VAL,
NUM_VAL,
EXPR_VAL
};
enum uof_init_type {
INIT_EXPR,
INIT_REG,
INIT_REG_CTX,
INIT_EXPR_ENDIAN_SWAP
};
struct uof_init_reg_sym {
u_int uirs_name;
char uirs_init_type;
char uirs_value_type;
char uirs_reg_type;
u_char uirs_ctx;
u_int uirs_addr_offset;
u_int uirs_value;
};
struct uof_sbreak {
u_int us_page_num;
u_int us_virt_uaddr;
u_char us_sbreak_type;
u_char us_reg_type;
u_short us_reserved1;
u_int us_addr_offset;
u_int us_reg_rddr;
};
struct uof_code_page {
u_int ucp_page_region;
u_int ucp_page_num;
u_char ucp_def_page;
u_char ucp_reserved2;
u_short ucp_reserved1;
u_int ucp_beg_vaddr;
u_int ucp_beg_paddr;
u_int ucp_neigh_reg_tab;
u_int ucp_uc_var_tab;
u_int ucp_imp_var_tab;
u_int ucp_imp_expr_tab;
u_int ucp_code_area;
};
struct uof_code_area {
u_int uca_num_micro_words;
u_int uca_uword_block_tab;
};
struct uof_uword_block {
u_int uub_start_addr;
u_int uub_num_words;
u_int uub_uword_offset;
u_int uub_reserved;
};
struct uof_uword_fixup {
u_int uuf_name;
u_int uuf_uword_address;
u_int uuf_expr_value;
u_char uuf_val_type;
u_char uuf_value_attrs;
u_short uuf_reserved1;
char uuf_field_attrs[UOF_FIELD_POS_SIZE];
};
struct uof_import_var {
u_int uiv_name;
u_char uiv_value_attrs;
u_char uiv_reserved1;
u_short uiv_reserved2;
uint64_t uiv_value;
};
struct uof_mem_val_attr {
u_int umva_byte_offset;
u_int umva_value;
};
enum uof_mem_region {
SRAM_REGION,
DRAM_REGION,
DRAM1_REGION,
LMEM_REGION,
SCRATCH_REGION,
UMEM_REGION,
RAM_REGION,
SHRAM_REGION,
SHRAM1_REGION,
SHRAM2_REGION,
SHRAM3_REGION,
SHRAM4_REGION,
SHRAM5_REGION
};
#define UOF_SCOPE_GLOBAL 0
#define UOF_SCOPE_LOCAL 1
struct uof_init_mem {
u_int uim_sym_name;
char uim_region;
char uim_scope;
u_short uim_reserved1;
u_int uim_addr;
u_int uim_num_bytes;
u_int uim_num_val_attr;
};
struct uof_var_mem_seg {
u_int uvms_sram_base;
u_int uvms_sram_size;
u_int uvms_sram_alignment;
u_int uvms_sdram_base;
u_int uvms_sdram_size;
u_int uvms_sdram_alignment;
u_int uvms_sdram1_base;
u_int uvms_sdram1_size;
u_int uvms_sdram1_alignment;
u_int uvms_scratch_base;
u_int uvms_scratch_size;
u_int uvms_scratch_alignment;
};
#define SUOF_OBJ_ID_LEN 8
#define SUOF_FID 0x53554f46
#define SUOF_MAJ_VER 0x0
#define SUOF_MIN_VER 0x1
#define SIMG_AE_INIT_SEQ_LEN (50 * sizeof(unsigned long long))
#define SIMG_AE_INSTS_LEN (0x4000 * sizeof(unsigned long long))
#define CSS_FWSK_MODULUS_LEN 256
#define CSS_FWSK_EXPONENT_LEN 4
#define CSS_FWSK_PAD_LEN 252
#define CSS_FWSK_PUB_LEN (CSS_FWSK_MODULUS_LEN + \
CSS_FWSK_EXPONENT_LEN + \
CSS_FWSK_PAD_LEN)
#define CSS_SIGNATURE_LEN 256
#define CSS_AE_IMG_LEN (sizeof(struct simg_ae_mode) + \
SIMG_AE_INIT_SEQ_LEN + \
SIMG_AE_INSTS_LEN)
#define CSS_AE_SIMG_LEN (sizeof(struct css_hdr) + \
CSS_FWSK_PUB_LEN + \
CSS_SIGNATURE_LEN + \
CSS_AE_IMG_LEN)
#define AE_IMG_OFFSET (sizeof(struct css_hdr) + \
CSS_FWSK_MODULUS_LEN + \
CSS_FWSK_EXPONENT_LEN + \
CSS_SIGNATURE_LEN)
#define CSS_MAX_IMAGE_LEN 0x40000
struct fw_auth_desc {
u_int fad_img_len;
u_int fad_reserved;
u_int fad_css_hdr_high;
u_int fad_css_hdr_low;
u_int fad_img_high;
u_int fad_img_low;
u_int fad_signature_high;
u_int fad_signature_low;
u_int fad_fwsk_pub_high;
u_int fad_fwsk_pub_low;
u_int fad_img_ae_mode_data_high;
u_int fad_img_ae_mode_data_low;
u_int fad_img_ae_init_data_high;
u_int fad_img_ae_init_data_low;
u_int fad_img_ae_insts_high;
u_int fad_img_ae_insts_low;
};
struct auth_chunk {
struct fw_auth_desc ac_fw_auth_desc;
uint64_t ac_chunk_size;
uint64_t ac_chunk_bus_addr;
};
enum css_fwtype {
CSS_AE_FIRMWARE = 0,
CSS_MMP_FIRMWARE = 1
};
struct css_hdr {
u_int css_module_type;
u_int css_header_len;
u_int css_header_ver;
u_int css_module_id;
u_int css_module_vendor;
u_int css_date;
u_int css_size;
u_int css_key_size;
u_int css_module_size;
u_int css_exponent_size;
u_int css_fw_type;
u_int css_reserved[21];
};
struct simg_ae_mode {
u_int sam_file_id;
u_short sam_maj_ver;
u_short sam_min_ver;
u_int sam_dev_type;
u_short sam_devmax_ver;
u_short sam_devmin_ver;
u_int sam_ae_mask;
u_int sam_ctx_enables;
char sam_fw_type;
char sam_ctx_mode;
char sam_nn_mode;
char sam_lm0_mode;
char sam_lm1_mode;
char sam_scs_mode;
char sam_lm2_mode;
char sam_lm3_mode;
char sam_tindex_mode;
u_char sam_reserved[7];
char sam_simg_name[256];
char sam_appmeta_data[256];
};
struct suof_file_hdr {
u_int sfh_file_id;
u_int sfh_check_sum;
char sfh_min_ver;
char sfh_maj_ver;
char sfh_fw_type;
char sfh_reserved;
u_short sfh_max_chunks;
u_short sfh_num_chunks;
};
struct suof_chunk_hdr {
char sch_chunk_id[SUOF_OBJ_ID_LEN];
uint64_t sch_offset;
uint64_t sch_size;
};
struct suof_str_tab {
u_int sst_tab_length;
u_int sst_strings;
};
struct suof_obj_hdr {
u_int soh_img_length;
u_int soh_reserved;
};
enum fw_slice {
FW_SLICE_NULL = 0,
FW_SLICE_CIPHER = 1,
FW_SLICE_AUTH = 2,
FW_SLICE_DRAM_RD = 3,
FW_SLICE_DRAM_WR = 4,
FW_SLICE_COMP = 5,
FW_SLICE_XLAT = 6,
FW_SLICE_DELIMITER
};
#define MAX_FW_SLICE FW_SLICE_DELIMITER
#define QAT_OPTIMAL_ALIGN_SHIFT 6
#define QAT_OPTIMAL_ALIGN (1 << QAT_OPTIMAL_ALIGN_SHIFT)
enum hw_auth_algo {
HW_AUTH_ALGO_NULL = 0,
HW_AUTH_ALGO_SHA1 = 1,
HW_AUTH_ALGO_MD5 = 2,
HW_AUTH_ALGO_SHA224 = 3,
HW_AUTH_ALGO_SHA256 = 4,
HW_AUTH_ALGO_SHA384 = 5,
HW_AUTH_ALGO_SHA512 = 6,
HW_AUTH_ALGO_AES_XCBC_MAC = 7,
HW_AUTH_ALGO_AES_CBC_MAC = 8,
HW_AUTH_ALGO_AES_F9 = 9,
HW_AUTH_ALGO_GALOIS_128 = 10,
HW_AUTH_ALGO_GALOIS_64 = 11,
HW_AUTH_ALGO_KASUMI_F9 = 12,
HW_AUTH_ALGO_SNOW_3G_UIA2 = 13,
HW_AUTH_ALGO_ZUC_3G_128_EIA3 = 14,
HW_AUTH_RESERVED_1 = 15,
HW_AUTH_RESERVED_2 = 16,
HW_AUTH_ALGO_SHA3_256 = 17,
HW_AUTH_RESERVED_3 = 18,
HW_AUTH_ALGO_SHA3_512 = 19,
HW_AUTH_ALGO_DELIMITER = 20
};
enum hw_auth_mode {
HW_AUTH_MODE0,
HW_AUTH_MODE1,
HW_AUTH_MODE2,
HW_AUTH_MODE_DELIMITER
};
struct hw_auth_config {
uint32_t config;
uint32_t reserved;
};
#define HW_AUTH_CONFIG_SHA3_ALGO __BITS(22, 23)
#define HW_AUTH_CONFIG_SHA3_PADDING __BIT(16)
#define HW_AUTH_CONFIG_CMPLEN __BITS(14, 8)
#define HW_AUTH_CONFIG_MODE __BITS(7, 4)
#define HW_AUTH_CONFIG_ALGO __BITS(3, 0)
#define HW_AUTH_CONFIG_BUILD(mode, algo, cmp_len) \
__SHIFTIN(mode, HW_AUTH_CONFIG_MODE) | \
__SHIFTIN(algo, HW_AUTH_CONFIG_ALGO) | \
__SHIFTIN(cmp_len, HW_AUTH_CONFIG_CMPLEN)
struct hw_auth_counter {
uint32_t counter;
uint32_t reserved;
};
struct hw_auth_setup {
struct hw_auth_config auth_config;
struct hw_auth_counter auth_counter;
};
#define HW_NULL_STATE1_SZ 32
#define HW_MD5_STATE1_SZ 16
#define HW_SHA1_STATE1_SZ 20
#define HW_SHA224_STATE1_SZ 32
#define HW_SHA256_STATE1_SZ 32
#define HW_SHA3_256_STATE1_SZ 32
#define HW_SHA384_STATE1_SZ 64
#define HW_SHA512_STATE1_SZ 64
#define HW_SHA3_512_STATE1_SZ 64
#define HW_SHA3_224_STATE1_SZ 28
#define HW_SHA3_384_STATE1_SZ 48
#define HW_AES_XCBC_MAC_STATE1_SZ 16
#define HW_AES_CBC_MAC_STATE1_SZ 16
#define HW_AES_F9_STATE1_SZ 32
#define HW_KASUMI_F9_STATE1_SZ 16
#define HW_GALOIS_128_STATE1_SZ 16
#define HW_SNOW_3G_UIA2_STATE1_SZ 8
#define HW_ZUC_3G_EIA3_STATE1_SZ 8
#define HW_NULL_STATE2_SZ 32
#define HW_MD5_STATE2_SZ 16
#define HW_SHA1_STATE2_SZ 20
#define HW_SHA224_STATE2_SZ 32
#define HW_SHA256_STATE2_SZ 32
#define HW_SHA3_256_STATE2_SZ 0
#define HW_SHA384_STATE2_SZ 64
#define HW_SHA512_STATE2_SZ 64
#define HW_SHA3_512_STATE2_SZ 0
#define HW_SHA3_224_STATE2_SZ 0
#define HW_SHA3_384_STATE2_SZ 0
#define HW_AES_XCBC_MAC_KEY_SZ 16
#define HW_AES_CBC_MAC_KEY_SZ 16
#define HW_AES_CCM_CBC_E_CTR0_SZ 16
#define HW_F9_IK_SZ 16
#define HW_F9_FK_SZ 16
#define HW_KASUMI_F9_STATE2_SZ (HW_F9_IK_SZ + HW_F9_FK_SZ)
#define HW_AES_F9_STATE2_SZ HW_KASUMI_F9_STATE2_SZ
#define HW_SNOW_3G_UIA2_STATE2_SZ 24
#define HW_ZUC_3G_EIA3_STATE2_SZ 32
#define HW_GALOIS_H_SZ 16
#define HW_GALOIS_LEN_A_SZ 8
#define HW_GALOIS_E_CTR0_SZ 16
struct hw_auth_sha512 {
struct hw_auth_setup inner_setup;
uint8_t state1[HW_SHA512_STATE1_SZ];
struct hw_auth_setup outer_setup;
uint8_t state2[HW_SHA512_STATE2_SZ];
};
union hw_auth_algo_blk {
struct hw_auth_sha512 max;
};
enum hw_cipher_algo {
HW_CIPHER_ALGO_NULL = 0,
HW_CIPHER_ALGO_DES = 1,
HW_CIPHER_ALGO_3DES = 2,
HW_CIPHER_ALGO_AES128 = 3,
HW_CIPHER_ALGO_AES192 = 4,
HW_CIPHER_ALGO_AES256 = 5,
HW_CIPHER_ALGO_ARC4 = 6,
HW_CIPHER_ALGO_KASUMI = 7,
HW_CIPHER_ALGO_SNOW_3G_UEA2 = 8,
HW_CIPHER_ALGO_ZUC_3G_128_EEA3 = 9,
HW_CIPHER_DELIMITER = 10
};
enum hw_cipher_mode {
HW_CIPHER_ECB_MODE = 0,
HW_CIPHER_CBC_MODE = 1,
HW_CIPHER_CTR_MODE = 2,
HW_CIPHER_F8_MODE = 3,
HW_CIPHER_XTS_MODE = 6,
HW_CIPHER_MODE_DELIMITER = 7
};
struct hw_cipher_config {
uint32_t val;
uint32_t reserved;
};
#define CIPHER_CONFIG_CONVERT __BIT(9)
#define CIPHER_CONFIG_DIR __BIT(8)
#define CIPHER_CONFIG_MODE __BITS(7, 4)
#define CIPHER_CONFIG_ALGO __BITS(3, 0)
#define HW_CIPHER_CONFIG_BUILD(mode, algo, convert, dir) \
__SHIFTIN(mode, CIPHER_CONFIG_MODE) | \
__SHIFTIN(algo, CIPHER_CONFIG_ALGO) | \
__SHIFTIN(convert, CIPHER_CONFIG_CONVERT) | \
__SHIFTIN(dir, CIPHER_CONFIG_DIR)
enum hw_cipher_dir {
HW_CIPHER_ENCRYPT = 0,
HW_CIPHER_DECRYPT = 1,
};
enum hw_cipher_convert {
HW_CIPHER_NO_CONVERT = 0,
HW_CIPHER_KEY_CONVERT = 1,
};
#define CIPHER_MODE_F8_KEY_SZ_MULT 2
#define CIPHER_MODE_XTS_KEY_SZ_MULT 2
#define HW_DES_BLK_SZ 8
#define HW_3DES_BLK_SZ 8
#define HW_NULL_BLK_SZ 8
#define HW_AES_BLK_SZ 16
#define HW_KASUMI_BLK_SZ 8
#define HW_SNOW_3G_BLK_SZ 8
#define HW_ZUC_3G_BLK_SZ 8
#define HW_NULL_KEY_SZ 256
#define HW_DES_KEY_SZ 8
#define HW_3DES_KEY_SZ 24
#define HW_AES_128_KEY_SZ 16
#define HW_AES_192_KEY_SZ 24
#define HW_AES_256_KEY_SZ 32
#define HW_AES_128_F8_KEY_SZ (HW_AES_128_KEY_SZ * \
CIPHER_MODE_F8_KEY_SZ_MULT)
#define HW_AES_192_F8_KEY_SZ (HW_AES_192_KEY_SZ * \
CIPHER_MODE_F8_KEY_SZ_MULT)
#define HW_AES_256_F8_KEY_SZ (HW_AES_256_KEY_SZ * \
CIPHER_MODE_F8_KEY_SZ_MULT)
#define HW_AES_128_XTS_KEY_SZ (HW_AES_128_KEY_SZ * \
CIPHER_MODE_XTS_KEY_SZ_MULT)
#define HW_AES_256_XTS_KEY_SZ (HW_AES_256_KEY_SZ * \
CIPHER_MODE_XTS_KEY_SZ_MULT)
#define HW_KASUMI_KEY_SZ 16
#define HW_KASUMI_F8_KEY_SZ (HW_KASUMI_KEY_SZ * \
CIPHER_MODE_F8_KEY_SZ_MULT)
#define HW_AES_128_XTS_KEY_SZ (HW_AES_128_KEY_SZ * \
CIPHER_MODE_XTS_KEY_SZ_MULT)
#define HW_AES_256_XTS_KEY_SZ (HW_AES_256_KEY_SZ * \
CIPHER_MODE_XTS_KEY_SZ_MULT)
#define HW_ARC4_KEY_SZ 256
#define HW_SNOW_3G_UEA2_KEY_SZ 16
#define HW_SNOW_3G_UEA2_IV_SZ 16
#define HW_ZUC_3G_EEA3_KEY_SZ 16
#define HW_ZUC_3G_EEA3_IV_SZ 16
#define HW_MODE_F8_NUM_REG_TO_CLEAR 2
struct hw_cipher_aes256_f8 {
struct hw_cipher_config cipher_config;
uint8_t key[HW_AES_256_F8_KEY_SZ];
};
union hw_cipher_algo_blk {
struct hw_cipher_aes256_f8 max;
};
struct flat_buffer_desc {
uint32_t data_len_in_bytes;
uint32_t reserved;
uint64_t phy_buffer;
};
#define HW_MAXSEG 32
struct buffer_list_desc {
uint64_t resrvd;
uint32_t num_buffers;
uint32_t reserved;
struct flat_buffer_desc flat_bufs[HW_MAXSEG];
};
enum fw_la_cmd_id {
FW_LA_CMD_CIPHER,
FW_LA_CMD_AUTH,
FW_LA_CMD_CIPHER_HASH,
FW_LA_CMD_HASH_CIPHER,
FW_LA_CMD_TRNG_GET_RANDOM,
FW_LA_CMD_TRNG_TEST,
FW_LA_CMD_SSL3_KEY_DERIVE,
FW_LA_CMD_TLS_V1_1_KEY_DERIVE,
FW_LA_CMD_TLS_V1_2_KEY_DERIVE,
FW_LA_CMD_MGF1,
FW_LA_CMD_AUTH_PRE_COMP,
#if 0
FW_LA_CMD_CIPHER_CIPHER,
FW_LA_CMD_HASH_HASH,
FW_LA_CMD_CIPHER_PRE_COMP,
#endif
FW_LA_CMD_DELIMITER,
};
#endif