Path: blob/master/drivers/accel/habanalabs/gaudi2/gaudi2P.h
26439 views
/* SPDX-License-Identifier: GPL-2.01*2* Copyright 2020-2022 HabanaLabs, Ltd.3* All Rights Reserved.4*5*/67#ifndef GAUDI2P_H_8#define GAUDI2P_H_910#include <uapi/drm/habanalabs_accel.h>11#include "../common/habanalabs.h"12#include <linux/habanalabs/hl_boot_if.h>13#include "../include/gaudi2/gaudi2.h"14#include "../include/gaudi2/gaudi2_packets.h"15#include "../include/gaudi2/gaudi2_fw_if.h"16#include "../include/gaudi2/gaudi2_async_events.h"1718#define GAUDI2_LINUX_FW_FILE "habanalabs/gaudi2/gaudi2-fit.itb"19#define GAUDI2_BOOT_FIT_FILE "habanalabs/gaudi2/gaudi2-boot-fit.itb"2021#define GAUDI2_CPU_TIMEOUT_USEC 30000000 /* 30s */2223#define NUMBER_OF_PDMA_QUEUES 224#define NUMBER_OF_EDMA_QUEUES 825#define NUMBER_OF_MME_QUEUES 426#define NUMBER_OF_TPC_QUEUES 2527#define NUMBER_OF_NIC_QUEUES 2428#define NUMBER_OF_ROT_QUEUES 229#define NUMBER_OF_CPU_QUEUES 13031#define NUMBER_OF_HW_QUEUES ((NUMBER_OF_PDMA_QUEUES + \32NUMBER_OF_EDMA_QUEUES + \33NUMBER_OF_MME_QUEUES + \34NUMBER_OF_TPC_QUEUES + \35NUMBER_OF_NIC_QUEUES + \36NUMBER_OF_ROT_QUEUES + \37NUMBER_OF_CPU_QUEUES) * \38NUM_OF_PQ_PER_QMAN)3940#define NUMBER_OF_QUEUES (NUMBER_OF_CPU_QUEUES + NUMBER_OF_HW_QUEUES)4142#define DCORE_NUM_OF_SOB \43(((mmDCORE0_SYNC_MNGR_OBJS_SOB_OBJ_8191 - \44mmDCORE0_SYNC_MNGR_OBJS_SOB_OBJ_0) + 4) >> 2)4546#define DCORE_NUM_OF_MONITORS \47(((mmDCORE0_SYNC_MNGR_OBJS_MON_STATUS_2047 - \48mmDCORE0_SYNC_MNGR_OBJS_MON_STATUS_0) + 4) >> 2)4950#define NUMBER_OF_DEC ((NUM_OF_DEC_PER_DCORE * NUM_OF_DCORES) + NUMBER_OF_PCIE_DEC)5152/* Map all arcs dccm + arc schedulers acp blocks */53#define NUM_OF_USER_ACP_BLOCKS (NUM_OF_SCHEDULER_ARC + 2)54#define NUM_OF_USER_NIC_UMR_BLOCKS 1555#define NUM_OF_EXPOSED_SM_BLOCKS ((NUM_OF_DCORES - 1) * 2)56#define NUM_USER_MAPPED_BLOCKS \57(NUM_ARC_CPUS + NUM_OF_USER_ACP_BLOCKS + NUMBER_OF_DEC + \58NUM_OF_EXPOSED_SM_BLOCKS + \59(NIC_NUMBER_OF_ENGINES * NUM_OF_USER_NIC_UMR_BLOCKS))6061/* Within the user mapped array, decoder entries start post all the ARC related62* entries63*/64#define USR_MAPPED_BLK_DEC_START_IDX \65(NUM_ARC_CPUS + NUM_OF_USER_ACP_BLOCKS + \66(NIC_NUMBER_OF_ENGINES * NUM_OF_USER_NIC_UMR_BLOCKS))6768#define USR_MAPPED_BLK_SM_START_IDX \69(NUM_ARC_CPUS + NUM_OF_USER_ACP_BLOCKS + NUMBER_OF_DEC + \70(NIC_NUMBER_OF_ENGINES * NUM_OF_USER_NIC_UMR_BLOCKS))7172#define SM_OBJS_BLOCK_SIZE (mmDCORE0_SYNC_MNGR_OBJS_SM_SEC_0 - \73mmDCORE0_SYNC_MNGR_OBJS_SOB_OBJ_0)7475#define GAUDI2_MAX_PENDING_CS 647677#if !IS_MAX_PENDING_CS_VALID(GAUDI2_MAX_PENDING_CS)78#error "GAUDI2_MAX_PENDING_CS must be power of 2 and greater than 1"79#endif8081#define CORESIGHT_TIMEOUT_USEC 100000 /* 100 ms */8283#define GAUDI2_PREBOOT_REQ_TIMEOUT_USEC 25000000 /* 25s */84#define GAUDI2_PREBOOT_EXTENDED_REQ_TIMEOUT_USEC 85000000 /* 85s */8586#define GAUDI2_BOOT_FIT_REQ_TIMEOUT_USEC 10000000 /* 10s */8788#define GAUDI2_NIC_CLK_FREQ 450000000ull /* 450 MHz */8990#define DC_POWER_DEFAULT 60000 /* 60W */9192#define GAUDI2_HBM_NUM 69394#define DMA_MAX_TRANSFER_SIZE U32_MAX9596#define GAUDI2_DEFAULT_CARD_NAME "HL225"9798#define QMAN_STREAMS 499100#define NUM_OF_MME_SBTE_PORTS 5101#define NUM_OF_MME_WB_PORTS 2102103#define GAUDI2_ENGINE_ID_DCORE_OFFSET \104(GAUDI2_DCORE1_ENGINE_ID_EDMA_0 - GAUDI2_DCORE0_ENGINE_ID_EDMA_0)105106/* DRAM Memory Map */107108#define CPU_FW_IMAGE_SIZE 0x10000000 /* 256MB */109#define CPU_FW_IMAGE_ADDR DRAM_PHYS_BASE110#define PMMU_PAGE_TABLES_SIZE 0x10000000 /* 256MB */111#define EDMA_PQS_SIZE SZ_2M112#define EDMA_SCRATCHPAD_SIZE SZ_1M113#define HMMU_PAGE_TABLES_SIZE SZ_1M114115#define NIC_NUMBER_OF_PORTS NIC_NUMBER_OF_ENGINES116117#define NUMBER_OF_PCIE_DEC 2118#define PCIE_DEC_SHIFT 8119120#define SRAM_USER_BASE_OFFSET 0121122/* cluster binning */123#define MAX_FAULTY_HBMS 1124#define GAUDI2_XBAR_EDGE_FULL_MASK 0xF125#define GAUDI2_EDMA_FULL_MASK 0xFF126#define GAUDI2_DRAM_FULL_MASK 0x3F127128/* Host virtual address space. */129130#define VA_HOST_SPACE_PAGE_START 0xFFF0000000000000ull131#define VA_HOST_SPACE_PAGE_END 0xFFF0800000000000ull /* 140TB */132133#define VA_HOST_SPACE_HPAGE_START 0xFFF0800000000000ull134#define VA_HOST_SPACE_HPAGE_END 0xFFF1000000000000ull /* 140TB */135136/* 140TB */137#define VA_HOST_SPACE_PAGE_SIZE (VA_HOST_SPACE_PAGE_END - VA_HOST_SPACE_PAGE_START)138139/* 140TB */140#define VA_HOST_SPACE_HPAGE_SIZE (VA_HOST_SPACE_HPAGE_END - VA_HOST_SPACE_HPAGE_START)141142#define VA_HOST_SPACE_SIZE (VA_HOST_SPACE_PAGE_SIZE + VA_HOST_SPACE_HPAGE_SIZE)143144#define HOST_SPACE_INTERNAL_CB_SZ SZ_2M145146/*147* HBM virtual address space148* Gaudi2 has 6 HBM devices, each supporting 16GB total of 96GB at most.149* No core separation is supported so we can have one chunk of virtual address150* space just above the physical ones.151* The virtual address space starts immediately after the end of the physical152* address space which is determined at run-time.153*/154#define VA_HBM_SPACE_END 0x1002000000000000ull155156#define HW_CAP_PLL BIT_ULL(0)157#define HW_CAP_DRAM BIT_ULL(1)158#define HW_CAP_PMMU BIT_ULL(2)159#define HW_CAP_CPU BIT_ULL(3)160#define HW_CAP_MSIX BIT_ULL(4)161162#define HW_CAP_CPU_Q BIT_ULL(5)163#define HW_CAP_CPU_Q_SHIFT 5164165#define HW_CAP_CLK_GATE BIT_ULL(6)166#define HW_CAP_KDMA BIT_ULL(7)167#define HW_CAP_SRAM_SCRAMBLER BIT_ULL(8)168169#define HW_CAP_DCORE0_DMMU0 BIT_ULL(9)170#define HW_CAP_DCORE0_DMMU1 BIT_ULL(10)171#define HW_CAP_DCORE0_DMMU2 BIT_ULL(11)172#define HW_CAP_DCORE0_DMMU3 BIT_ULL(12)173#define HW_CAP_DCORE1_DMMU0 BIT_ULL(13)174#define HW_CAP_DCORE1_DMMU1 BIT_ULL(14)175#define HW_CAP_DCORE1_DMMU2 BIT_ULL(15)176#define HW_CAP_DCORE1_DMMU3 BIT_ULL(16)177#define HW_CAP_DCORE2_DMMU0 BIT_ULL(17)178#define HW_CAP_DCORE2_DMMU1 BIT_ULL(18)179#define HW_CAP_DCORE2_DMMU2 BIT_ULL(19)180#define HW_CAP_DCORE2_DMMU3 BIT_ULL(20)181#define HW_CAP_DCORE3_DMMU0 BIT_ULL(21)182#define HW_CAP_DCORE3_DMMU1 BIT_ULL(22)183#define HW_CAP_DCORE3_DMMU2 BIT_ULL(23)184#define HW_CAP_DCORE3_DMMU3 BIT_ULL(24)185#define HW_CAP_DMMU_MASK GENMASK_ULL(24, 9)186#define HW_CAP_DMMU_SHIFT 9187#define HW_CAP_PDMA_MASK BIT_ULL(26)188#define HW_CAP_EDMA_MASK GENMASK_ULL(34, 27)189#define HW_CAP_EDMA_SHIFT 27190#define HW_CAP_MME_MASK GENMASK_ULL(38, 35)191#define HW_CAP_MME_SHIFT 35192#define HW_CAP_ROT_MASK GENMASK_ULL(40, 39)193#define HW_CAP_ROT_SHIFT 39194#define HW_CAP_HBM_SCRAMBLER_HW_RESET BIT_ULL(41)195#define HW_CAP_HBM_SCRAMBLER_SW_RESET BIT_ULL(42)196#define HW_CAP_HBM_SCRAMBLER_MASK (HW_CAP_HBM_SCRAMBLER_HW_RESET | \197HW_CAP_HBM_SCRAMBLER_SW_RESET)198#define HW_CAP_HBM_SCRAMBLER_SHIFT 41199#define HW_CAP_RESERVED BIT(43)200#define HW_CAP_MMU_MASK (HW_CAP_PMMU | HW_CAP_DMMU_MASK)201202/* Range Registers */203#define RR_TYPE_SHORT 0204#define RR_TYPE_LONG 1205#define RR_TYPE_SHORT_PRIV 2206#define RR_TYPE_LONG_PRIV 3207#define NUM_SHORT_LBW_RR 14208#define NUM_LONG_LBW_RR 4209#define NUM_SHORT_HBW_RR 6210#define NUM_LONG_HBW_RR 4211212/* RAZWI initiator coordinates- X- 5 bits, Y- 4 bits */213#define RAZWI_INITIATOR_X_SHIFT 0214#define RAZWI_INITIATOR_X_MASK 0x1F215#define RAZWI_INITIATOR_Y_SHIFT 5216#define RAZWI_INITIATOR_Y_MASK 0xF217218#define RTR_ID_X_Y(x, y) \219((((y) & RAZWI_INITIATOR_Y_MASK) << RAZWI_INITIATOR_Y_SHIFT) | \220(((x) & RAZWI_INITIATOR_X_MASK) << RAZWI_INITIATOR_X_SHIFT))221222/* decoders have separate mask */223#define HW_CAP_DEC_SHIFT 0224#define HW_CAP_DEC_MASK GENMASK_ULL(9, 0)225226/* TPCs have separate mask */227#define HW_CAP_TPC_SHIFT 0228#define HW_CAP_TPC_MASK GENMASK_ULL(24, 0)229230/* nics have separate mask */231#define HW_CAP_NIC_SHIFT 0232#define HW_CAP_NIC_MASK GENMASK_ULL(NIC_NUMBER_OF_ENGINES - 1, 0)233234#define GAUDI2_ARC_PCI_MSB_ADDR(addr) (((addr) & GENMASK_ULL(49, 28)) >> 28)235236#define GAUDI2_SOB_INCREMENT_BY_ONE (FIELD_PREP(DCORE0_SYNC_MNGR_OBJS_SOB_OBJ_VAL_MASK, 1) | \237FIELD_PREP(DCORE0_SYNC_MNGR_OBJS_SOB_OBJ_INC_MASK, 1))238239#define GAUDI2_NUM_TESTED_QS (GAUDI2_QUEUE_ID_CPU_PQ - GAUDI2_QUEUE_ID_PDMA_0_0)240241242enum gaudi2_reserved_sob_id {243GAUDI2_RESERVED_SOB_CS_COMPLETION_FIRST,244GAUDI2_RESERVED_SOB_CS_COMPLETION_LAST =245GAUDI2_RESERVED_SOB_CS_COMPLETION_FIRST + GAUDI2_MAX_PENDING_CS - 1,246GAUDI2_RESERVED_SOB_KDMA_COMPLETION,247GAUDI2_RESERVED_SOB_DEC_NRM_FIRST,248GAUDI2_RESERVED_SOB_DEC_NRM_LAST =249GAUDI2_RESERVED_SOB_DEC_NRM_FIRST + NUMBER_OF_DEC - 1,250GAUDI2_RESERVED_SOB_DEC_ABNRM_FIRST,251GAUDI2_RESERVED_SOB_DEC_ABNRM_LAST =252GAUDI2_RESERVED_SOB_DEC_ABNRM_FIRST + NUMBER_OF_DEC - 1,253GAUDI2_RESERVED_SOB_NUMBER254};255256enum gaudi2_reserved_mon_id {257GAUDI2_RESERVED_MON_CS_COMPLETION_FIRST,258GAUDI2_RESERVED_MON_CS_COMPLETION_LAST =259GAUDI2_RESERVED_MON_CS_COMPLETION_FIRST + GAUDI2_MAX_PENDING_CS - 1,260GAUDI2_RESERVED_MON_KDMA_COMPLETION,261GAUDI2_RESERVED_MON_DEC_NRM_FIRST,262GAUDI2_RESERVED_MON_DEC_NRM_LAST =263GAUDI2_RESERVED_MON_DEC_NRM_FIRST + 3 * NUMBER_OF_DEC - 1,264GAUDI2_RESERVED_MON_DEC_ABNRM_FIRST,265GAUDI2_RESERVED_MON_DEC_ABNRM_LAST =266GAUDI2_RESERVED_MON_DEC_ABNRM_FIRST + 3 * NUMBER_OF_DEC - 1,267GAUDI2_RESERVED_MON_NUMBER268};269270enum gaudi2_reserved_cq_id {271GAUDI2_RESERVED_CQ_CS_COMPLETION,272GAUDI2_RESERVED_CQ_KDMA_COMPLETION,273GAUDI2_RESERVED_CQ_NUMBER274};275276/*277* Gaudi2 subtitute TPCs Numbering278* At most- two faulty TPCs are allowed279* First replacement to a faulty TPC will be TPC24, second- TPC23280*/281enum substitude_tpc {282FAULTY_TPC_SUBTS_1_TPC_24,283FAULTY_TPC_SUBTS_2_TPC_23,284MAX_FAULTY_TPCS285};286287enum gaudi2_dma_core_id {288DMA_CORE_ID_PDMA0, /* Dcore 0 */289DMA_CORE_ID_PDMA1, /* Dcore 0 */290DMA_CORE_ID_EDMA0, /* Dcore 0 */291DMA_CORE_ID_EDMA1, /* Dcore 0 */292DMA_CORE_ID_EDMA2, /* Dcore 1 */293DMA_CORE_ID_EDMA3, /* Dcore 1 */294DMA_CORE_ID_EDMA4, /* Dcore 2 */295DMA_CORE_ID_EDMA5, /* Dcore 2 */296DMA_CORE_ID_EDMA6, /* Dcore 3 */297DMA_CORE_ID_EDMA7, /* Dcore 3 */298DMA_CORE_ID_KDMA, /* Dcore 0 */299DMA_CORE_ID_SIZE300};301302enum gaudi2_rotator_id {303ROTATOR_ID_0,304ROTATOR_ID_1,305ROTATOR_ID_SIZE,306};307308enum gaudi2_mme_id {309MME_ID_DCORE0,310MME_ID_DCORE1,311MME_ID_DCORE2,312MME_ID_DCORE3,313MME_ID_SIZE,314};315316enum gaudi2_tpc_id {317TPC_ID_DCORE0_TPC0,318TPC_ID_DCORE0_TPC1,319TPC_ID_DCORE0_TPC2,320TPC_ID_DCORE0_TPC3,321TPC_ID_DCORE0_TPC4,322TPC_ID_DCORE0_TPC5,323TPC_ID_DCORE1_TPC0,324TPC_ID_DCORE1_TPC1,325TPC_ID_DCORE1_TPC2,326TPC_ID_DCORE1_TPC3,327TPC_ID_DCORE1_TPC4,328TPC_ID_DCORE1_TPC5,329TPC_ID_DCORE2_TPC0,330TPC_ID_DCORE2_TPC1,331TPC_ID_DCORE2_TPC2,332TPC_ID_DCORE2_TPC3,333TPC_ID_DCORE2_TPC4,334TPC_ID_DCORE2_TPC5,335TPC_ID_DCORE3_TPC0,336TPC_ID_DCORE3_TPC1,337TPC_ID_DCORE3_TPC2,338TPC_ID_DCORE3_TPC3,339TPC_ID_DCORE3_TPC4,340TPC_ID_DCORE3_TPC5,341/* the PCI TPC is placed last (mapped liked HW) */342TPC_ID_DCORE0_TPC6,343TPC_ID_SIZE,344};345346enum gaudi2_dec_id {347DEC_ID_DCORE0_DEC0,348DEC_ID_DCORE0_DEC1,349DEC_ID_DCORE1_DEC0,350DEC_ID_DCORE1_DEC1,351DEC_ID_DCORE2_DEC0,352DEC_ID_DCORE2_DEC1,353DEC_ID_DCORE3_DEC0,354DEC_ID_DCORE3_DEC1,355DEC_ID_PCIE_VDEC0,356DEC_ID_PCIE_VDEC1,357DEC_ID_SIZE,358};359360enum gaudi2_hbm_id {361HBM_ID0,362HBM_ID1,363HBM_ID2,364HBM_ID3,365HBM_ID4,366HBM_ID5,367HBM_ID_SIZE,368};369370/* specific EDMA enumeration */371enum gaudi2_edma_id {372EDMA_ID_DCORE0_INSTANCE0,373EDMA_ID_DCORE0_INSTANCE1,374EDMA_ID_DCORE1_INSTANCE0,375EDMA_ID_DCORE1_INSTANCE1,376EDMA_ID_DCORE2_INSTANCE0,377EDMA_ID_DCORE2_INSTANCE1,378EDMA_ID_DCORE3_INSTANCE0,379EDMA_ID_DCORE3_INSTANCE1,380EDMA_ID_SIZE,381};382383/* User interrupt count is aligned with HW CQ count.384* We have 64 CQ's per dcore, CQ0 in dcore 0 is reserved for legacy mode385*/386#define GAUDI2_NUM_USER_INTERRUPTS 64387#define GAUDI2_NUM_RESERVED_INTERRUPTS 1388#define GAUDI2_TOTAL_USER_INTERRUPTS (GAUDI2_NUM_USER_INTERRUPTS + GAUDI2_NUM_RESERVED_INTERRUPTS)389390enum gaudi2_irq_num {391GAUDI2_IRQ_NUM_EVENT_QUEUE = GAUDI2_EVENT_QUEUE_MSIX_IDX,392GAUDI2_IRQ_NUM_DCORE0_DEC0_NRM,393GAUDI2_IRQ_NUM_DCORE0_DEC0_ABNRM,394GAUDI2_IRQ_NUM_DCORE0_DEC1_NRM,395GAUDI2_IRQ_NUM_DCORE0_DEC1_ABNRM,396GAUDI2_IRQ_NUM_DCORE1_DEC0_NRM,397GAUDI2_IRQ_NUM_DCORE1_DEC0_ABNRM,398GAUDI2_IRQ_NUM_DCORE1_DEC1_NRM,399GAUDI2_IRQ_NUM_DCORE1_DEC1_ABNRM,400GAUDI2_IRQ_NUM_DCORE2_DEC0_NRM,401GAUDI2_IRQ_NUM_DCORE2_DEC0_ABNRM,402GAUDI2_IRQ_NUM_DCORE2_DEC1_NRM,403GAUDI2_IRQ_NUM_DCORE2_DEC1_ABNRM,404GAUDI2_IRQ_NUM_DCORE3_DEC0_NRM,405GAUDI2_IRQ_NUM_DCORE3_DEC0_ABNRM,406GAUDI2_IRQ_NUM_DCORE3_DEC1_NRM,407GAUDI2_IRQ_NUM_DCORE3_DEC1_ABNRM,408GAUDI2_IRQ_NUM_SHARED_DEC0_NRM,409GAUDI2_IRQ_NUM_SHARED_DEC0_ABNRM,410GAUDI2_IRQ_NUM_SHARED_DEC1_NRM,411GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM,412GAUDI2_IRQ_NUM_DEC_LAST = GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM,413GAUDI2_IRQ_NUM_COMPLETION,414GAUDI2_IRQ_NUM_NIC_PORT_FIRST,415GAUDI2_IRQ_NUM_NIC_PORT_LAST = (GAUDI2_IRQ_NUM_NIC_PORT_FIRST + NIC_NUMBER_OF_PORTS - 1),416GAUDI2_IRQ_NUM_TPC_ASSERT,417GAUDI2_IRQ_NUM_EQ_ERROR,418GAUDI2_IRQ_NUM_USER_FIRST,419GAUDI2_IRQ_NUM_USER_LAST = (GAUDI2_IRQ_NUM_USER_FIRST + GAUDI2_NUM_USER_INTERRUPTS - 1),420GAUDI2_IRQ_NUM_RESERVED_FIRST,421GAUDI2_IRQ_NUM_RESERVED_LAST = (GAUDI2_MSIX_ENTRIES - GAUDI2_NUM_RESERVED_INTERRUPTS - 1),422GAUDI2_IRQ_NUM_UNEXPECTED_ERROR = RESERVED_MSIX_UNEXPECTED_USER_ERROR_INTERRUPT,423GAUDI2_IRQ_NUM_LAST = (GAUDI2_MSIX_ENTRIES - 1)424};425426static_assert(GAUDI2_IRQ_NUM_USER_FIRST > GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM);427428/**429* struct dup_block_ctx - context to initialize unit instances across multiple430* blocks where block can be either a dcore of duplicated431* common module. this code relies on constant offsets432* of blocks and unit instances in a block.433* @instance_cfg_fn: instance specific configuration function.434* @data: private configuration data.435* @base: base address of the first instance in the first block.436* @block_off: subsequent blocks address spacing.437* @instance_off: subsequent block's instances address spacing.438* @enabled_mask: mask of enabled instances (1- enabled, 0- disabled).439* @blocks: number of blocks.440* @instances: unit instances per block.441*/442struct dup_block_ctx {443void (*instance_cfg_fn)(struct hl_device *hdev, u64 base, void *data);444void *data;445u64 base;446u64 block_off;447u64 instance_off;448u64 enabled_mask;449unsigned int blocks;450unsigned int instances;451};452453/**454* struct gaudi2_queues_test_info - Holds the address of a the messages used for testing the455* device queues.456* @dma_addr: the address used by the HW for accessing the message.457* @kern_addr: The address used by the driver for accessing the message.458*/459struct gaudi2_queues_test_info {460dma_addr_t dma_addr;461void *kern_addr;462};463464/**465* struct gaudi2_device - ASIC specific manage structure.466* @cpucp_info_get: get information on device from CPU-CP467* @mapped_blocks: array that holds the base address and size of all blocks468* the user can map.469* @lfsr_rand_seeds: array of MME ACC random seeds to set.470* @hw_queues_lock: protects the H/W queues from concurrent access.471* @scratchpad_kernel_address: general purpose PAGE_SIZE contiguous memory,472* this memory region should be write-only.473* currently used for HBW QMAN writes which is474* redundant.475* @scratchpad_bus_address: scratchpad bus address476* @virt_msix_db_cpu_addr: host memory page for the virtual MSI-X doorbell.477* @virt_msix_db_dma_addr: bus address of the page for the virtual MSI-X doorbell.478* @dram_bar_cur_addr: current address of DRAM PCI bar.479* @hw_cap_initialized: This field contains a bit per H/W engine. When that480* engine is initialized, that bit is set by the driver to481* signal we can use this engine in later code paths.482* Each bit is cleared upon reset of its corresponding H/W483* engine.484* @active_hw_arc: This field contains a bit per ARC of an H/W engine with485* exception of TPC and NIC engines. Once an engine arc is486* initialized, its respective bit is set. Driver can uniquely487* identify each initialized ARC and use this information in488* later code paths. Each respective bit is cleared upon reset489* of its corresponding ARC of the H/W engine.490* @dec_hw_cap_initialized: This field contains a bit per decoder H/W engine.491* When that engine is initialized, that bit is set by492* the driver to signal we can use this engine in later493* code paths.494* Each bit is cleared upon reset of its corresponding H/W495* engine.496* @tpc_hw_cap_initialized: This field contains a bit per TPC H/W engine.497* When that engine is initialized, that bit is set by498* the driver to signal we can use this engine in later499* code paths.500* Each bit is cleared upon reset of its corresponding H/W501* engine.502* @active_tpc_arc: This field contains a bit per ARC of the TPC engines.503* Once an engine arc is initialized, its respective bit is504* set. Each respective bit is cleared upon reset of its505* corresponding ARC of the TPC engine.506* @nic_hw_cap_initialized: This field contains a bit per nic H/W engine.507* @active_nic_arc: This field contains a bit per ARC of the NIC engines.508* Once an engine arc is initialized, its respective bit is509* set. Each respective bit is cleared upon reset of its510* corresponding ARC of the NIC engine.511* @hw_events: array that holds all H/W events that are defined valid.512* @events_stat: array that holds histogram of all received events.513* @events_stat_aggregate: same as events_stat but doesn't get cleared on reset.514* @num_of_valid_hw_events: used to hold the number of valid H/W events.515* @nic_ports: array that holds all NIC ports manage structures.516* @nic_macros: array that holds all NIC macro manage structures.517* @core_info: core info to be used by the Ethernet driver.518* @aux_ops: functions for core <-> aux drivers communication.519* @flush_db_fifo: flag to force flush DB FIFO after a write.520* @hbm_cfg: HBM subsystem settings521* @hw_queues_lock_mutex: used by simulator instead of hw_queues_lock.522* @queues_test_info: information used by the driver when testing the HW queues.523*/524struct gaudi2_device {525int (*cpucp_info_get)(struct hl_device *hdev);526527struct user_mapped_block mapped_blocks[NUM_USER_MAPPED_BLOCKS];528int lfsr_rand_seeds[MME_NUM_OF_LFSR_SEEDS];529530spinlock_t hw_queues_lock;531532void *scratchpad_kernel_address;533dma_addr_t scratchpad_bus_address;534535void *virt_msix_db_cpu_addr;536dma_addr_t virt_msix_db_dma_addr;537538u64 dram_bar_cur_addr;539u64 hw_cap_initialized;540u64 active_hw_arc;541u64 dec_hw_cap_initialized;542u64 tpc_hw_cap_initialized;543u64 active_tpc_arc;544u64 nic_hw_cap_initialized;545u64 active_nic_arc;546u32 hw_events[GAUDI2_EVENT_SIZE];547u32 events_stat[GAUDI2_EVENT_SIZE];548u32 events_stat_aggregate[GAUDI2_EVENT_SIZE];549u32 num_of_valid_hw_events;550551/* Queue testing */552struct gaudi2_queues_test_info queues_test_info[GAUDI2_NUM_TESTED_QS];553};554555/*556* Types of the Gaudi2 IP blocks, used by special blocks iterator.557* Required for scenarios where only particular block types can be558* addressed (e.g., special PLDM images).559*/560enum gaudi2_block_types {561GAUDI2_BLOCK_TYPE_PLL,562GAUDI2_BLOCK_TYPE_RTR,563GAUDI2_BLOCK_TYPE_CPU,564GAUDI2_BLOCK_TYPE_HIF,565GAUDI2_BLOCK_TYPE_HBM,566GAUDI2_BLOCK_TYPE_NIC,567GAUDI2_BLOCK_TYPE_PCIE,568GAUDI2_BLOCK_TYPE_PCIE_PMA,569GAUDI2_BLOCK_TYPE_PDMA,570GAUDI2_BLOCK_TYPE_EDMA,571GAUDI2_BLOCK_TYPE_PMMU,572GAUDI2_BLOCK_TYPE_PSOC,573GAUDI2_BLOCK_TYPE_ROT,574GAUDI2_BLOCK_TYPE_ARC_FARM,575GAUDI2_BLOCK_TYPE_DEC,576GAUDI2_BLOCK_TYPE_MME,577GAUDI2_BLOCK_TYPE_EU_BIST,578GAUDI2_BLOCK_TYPE_SYNC_MNGR,579GAUDI2_BLOCK_TYPE_STLB,580GAUDI2_BLOCK_TYPE_TPC,581GAUDI2_BLOCK_TYPE_HMMU,582GAUDI2_BLOCK_TYPE_SRAM,583GAUDI2_BLOCK_TYPE_XBAR,584GAUDI2_BLOCK_TYPE_KDMA,585GAUDI2_BLOCK_TYPE_XDMA,586GAUDI2_BLOCK_TYPE_XFT,587GAUDI2_BLOCK_TYPE_MAX588};589590extern const u32 gaudi2_dma_core_blocks_bases[DMA_CORE_ID_SIZE];591extern const u32 gaudi2_qm_blocks_bases[GAUDI2_QUEUE_ID_SIZE];592extern const u32 gaudi2_mme_acc_blocks_bases[MME_ID_SIZE];593extern const u32 gaudi2_mme_ctrl_lo_blocks_bases[MME_ID_SIZE];594extern const u32 edma_stream_base[NUM_OF_EDMA_PER_DCORE * NUM_OF_DCORES];595extern const u32 gaudi2_rot_blocks_bases[ROTATOR_ID_SIZE];596597void gaudi2_iterate_tpcs(struct hl_device *hdev, struct iterate_module_ctx *ctx);598int gaudi2_coresight_init(struct hl_device *hdev);599int gaudi2_debug_coresight(struct hl_device *hdev, struct hl_ctx *ctx, void *data);600void gaudi2_halt_coresight(struct hl_device *hdev, struct hl_ctx *ctx);601void gaudi2_init_blocks(struct hl_device *hdev, struct dup_block_ctx *cfg_ctx);602bool gaudi2_is_hmmu_enabled(struct hl_device *hdev, int dcore_id, int hmmu_id);603void gaudi2_write_rr_to_all_lbw_rtrs(struct hl_device *hdev, u8 rr_type, u32 rr_index, u64 min_val,604u64 max_val);605void gaudi2_pb_print_security_errors(struct hl_device *hdev, u32 block_addr, u32 cause,606u32 offended_addr);607int gaudi2_init_security(struct hl_device *hdev);608void gaudi2_ack_protection_bits_errors(struct hl_device *hdev);609int gaudi2_send_device_activity(struct hl_device *hdev, bool open);610611#endif /* GAUDI2P_H_ */612613614