Path: blob/master/drivers/accel/habanalabs/gaudi2/gaudi2P.h
29286 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)240241242extern const char *gaudi2_engine_id_str[];243extern const char *gaudi2_queue_id_str[];244245#define GAUDI2_ENG_ID_TO_STR(initiator) ((initiator) >= GAUDI2_ENGINE_ID_SIZE ? "not found" : \246gaudi2_engine_id_str[initiator])247248#define GAUDI2_QUEUE_ID_TO_STR(initiator) ((initiator) >= GAUDI2_QUEUE_ID_SIZE ? "not found" : \249gaudi2_queue_id_str[initiator])250251enum gaudi2_reserved_sob_id {252GAUDI2_RESERVED_SOB_CS_COMPLETION_FIRST,253GAUDI2_RESERVED_SOB_CS_COMPLETION_LAST =254GAUDI2_RESERVED_SOB_CS_COMPLETION_FIRST + GAUDI2_MAX_PENDING_CS - 1,255GAUDI2_RESERVED_SOB_KDMA_COMPLETION,256GAUDI2_RESERVED_SOB_DEC_NRM_FIRST,257GAUDI2_RESERVED_SOB_DEC_NRM_LAST =258GAUDI2_RESERVED_SOB_DEC_NRM_FIRST + NUMBER_OF_DEC - 1,259GAUDI2_RESERVED_SOB_DEC_ABNRM_FIRST,260GAUDI2_RESERVED_SOB_DEC_ABNRM_LAST =261GAUDI2_RESERVED_SOB_DEC_ABNRM_FIRST + NUMBER_OF_DEC - 1,262GAUDI2_RESERVED_SOB_NUMBER263};264265enum gaudi2_reserved_mon_id {266GAUDI2_RESERVED_MON_CS_COMPLETION_FIRST,267GAUDI2_RESERVED_MON_CS_COMPLETION_LAST =268GAUDI2_RESERVED_MON_CS_COMPLETION_FIRST + GAUDI2_MAX_PENDING_CS - 1,269GAUDI2_RESERVED_MON_KDMA_COMPLETION,270GAUDI2_RESERVED_MON_DEC_NRM_FIRST,271GAUDI2_RESERVED_MON_DEC_NRM_LAST =272GAUDI2_RESERVED_MON_DEC_NRM_FIRST + 3 * NUMBER_OF_DEC - 1,273GAUDI2_RESERVED_MON_DEC_ABNRM_FIRST,274GAUDI2_RESERVED_MON_DEC_ABNRM_LAST =275GAUDI2_RESERVED_MON_DEC_ABNRM_FIRST + 3 * NUMBER_OF_DEC - 1,276GAUDI2_RESERVED_MON_NUMBER277};278279enum gaudi2_reserved_cq_id {280GAUDI2_RESERVED_CQ_CS_COMPLETION,281GAUDI2_RESERVED_CQ_KDMA_COMPLETION,282GAUDI2_RESERVED_CQ_NUMBER283};284285/*286* Gaudi2 subtitute TPCs Numbering287* At most- two faulty TPCs are allowed288* First replacement to a faulty TPC will be TPC24, second- TPC23289*/290enum substitude_tpc {291FAULTY_TPC_SUBTS_1_TPC_24,292FAULTY_TPC_SUBTS_2_TPC_23,293MAX_FAULTY_TPCS294};295296enum gaudi2_dma_core_id {297DMA_CORE_ID_PDMA0, /* Dcore 0 */298DMA_CORE_ID_PDMA1, /* Dcore 0 */299DMA_CORE_ID_EDMA0, /* Dcore 0 */300DMA_CORE_ID_EDMA1, /* Dcore 0 */301DMA_CORE_ID_EDMA2, /* Dcore 1 */302DMA_CORE_ID_EDMA3, /* Dcore 1 */303DMA_CORE_ID_EDMA4, /* Dcore 2 */304DMA_CORE_ID_EDMA5, /* Dcore 2 */305DMA_CORE_ID_EDMA6, /* Dcore 3 */306DMA_CORE_ID_EDMA7, /* Dcore 3 */307DMA_CORE_ID_KDMA, /* Dcore 0 */308DMA_CORE_ID_SIZE309};310311enum gaudi2_rotator_id {312ROTATOR_ID_0,313ROTATOR_ID_1,314ROTATOR_ID_SIZE,315};316317enum gaudi2_mme_id {318MME_ID_DCORE0,319MME_ID_DCORE1,320MME_ID_DCORE2,321MME_ID_DCORE3,322MME_ID_SIZE,323};324325enum gaudi2_tpc_id {326TPC_ID_DCORE0_TPC0,327TPC_ID_DCORE0_TPC1,328TPC_ID_DCORE0_TPC2,329TPC_ID_DCORE0_TPC3,330TPC_ID_DCORE0_TPC4,331TPC_ID_DCORE0_TPC5,332TPC_ID_DCORE1_TPC0,333TPC_ID_DCORE1_TPC1,334TPC_ID_DCORE1_TPC2,335TPC_ID_DCORE1_TPC3,336TPC_ID_DCORE1_TPC4,337TPC_ID_DCORE1_TPC5,338TPC_ID_DCORE2_TPC0,339TPC_ID_DCORE2_TPC1,340TPC_ID_DCORE2_TPC2,341TPC_ID_DCORE2_TPC3,342TPC_ID_DCORE2_TPC4,343TPC_ID_DCORE2_TPC5,344TPC_ID_DCORE3_TPC0,345TPC_ID_DCORE3_TPC1,346TPC_ID_DCORE3_TPC2,347TPC_ID_DCORE3_TPC3,348TPC_ID_DCORE3_TPC4,349TPC_ID_DCORE3_TPC5,350/* the PCI TPC is placed last (mapped liked HW) */351TPC_ID_DCORE0_TPC6,352TPC_ID_SIZE,353};354355enum gaudi2_dec_id {356DEC_ID_DCORE0_DEC0,357DEC_ID_DCORE0_DEC1,358DEC_ID_DCORE1_DEC0,359DEC_ID_DCORE1_DEC1,360DEC_ID_DCORE2_DEC0,361DEC_ID_DCORE2_DEC1,362DEC_ID_DCORE3_DEC0,363DEC_ID_DCORE3_DEC1,364DEC_ID_PCIE_VDEC0,365DEC_ID_PCIE_VDEC1,366DEC_ID_SIZE,367};368369enum gaudi2_hbm_id {370HBM_ID0,371HBM_ID1,372HBM_ID2,373HBM_ID3,374HBM_ID4,375HBM_ID5,376HBM_ID_SIZE,377};378379/* specific EDMA enumeration */380enum gaudi2_edma_id {381EDMA_ID_DCORE0_INSTANCE0,382EDMA_ID_DCORE0_INSTANCE1,383EDMA_ID_DCORE1_INSTANCE0,384EDMA_ID_DCORE1_INSTANCE1,385EDMA_ID_DCORE2_INSTANCE0,386EDMA_ID_DCORE2_INSTANCE1,387EDMA_ID_DCORE3_INSTANCE0,388EDMA_ID_DCORE3_INSTANCE1,389EDMA_ID_SIZE,390};391392/* User interrupt count is aligned with HW CQ count.393* We have 64 CQ's per dcore, CQ0 in dcore 0 is reserved for legacy mode394*/395#define GAUDI2_NUM_USER_INTERRUPTS 64396#define GAUDI2_NUM_RESERVED_INTERRUPTS 1397#define GAUDI2_TOTAL_USER_INTERRUPTS (GAUDI2_NUM_USER_INTERRUPTS + GAUDI2_NUM_RESERVED_INTERRUPTS)398399enum gaudi2_irq_num {400GAUDI2_IRQ_NUM_EVENT_QUEUE = GAUDI2_EVENT_QUEUE_MSIX_IDX,401GAUDI2_IRQ_NUM_DCORE0_DEC0_NRM,402GAUDI2_IRQ_NUM_DCORE0_DEC0_ABNRM,403GAUDI2_IRQ_NUM_DCORE0_DEC1_NRM,404GAUDI2_IRQ_NUM_DCORE0_DEC1_ABNRM,405GAUDI2_IRQ_NUM_DCORE1_DEC0_NRM,406GAUDI2_IRQ_NUM_DCORE1_DEC0_ABNRM,407GAUDI2_IRQ_NUM_DCORE1_DEC1_NRM,408GAUDI2_IRQ_NUM_DCORE1_DEC1_ABNRM,409GAUDI2_IRQ_NUM_DCORE2_DEC0_NRM,410GAUDI2_IRQ_NUM_DCORE2_DEC0_ABNRM,411GAUDI2_IRQ_NUM_DCORE2_DEC1_NRM,412GAUDI2_IRQ_NUM_DCORE2_DEC1_ABNRM,413GAUDI2_IRQ_NUM_DCORE3_DEC0_NRM,414GAUDI2_IRQ_NUM_DCORE3_DEC0_ABNRM,415GAUDI2_IRQ_NUM_DCORE3_DEC1_NRM,416GAUDI2_IRQ_NUM_DCORE3_DEC1_ABNRM,417GAUDI2_IRQ_NUM_SHARED_DEC0_NRM,418GAUDI2_IRQ_NUM_SHARED_DEC0_ABNRM,419GAUDI2_IRQ_NUM_SHARED_DEC1_NRM,420GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM,421GAUDI2_IRQ_NUM_DEC_LAST = GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM,422GAUDI2_IRQ_NUM_COMPLETION,423GAUDI2_IRQ_NUM_NIC_PORT_FIRST,424GAUDI2_IRQ_NUM_NIC_PORT_LAST = (GAUDI2_IRQ_NUM_NIC_PORT_FIRST + NIC_NUMBER_OF_PORTS - 1),425GAUDI2_IRQ_NUM_TPC_ASSERT,426GAUDI2_IRQ_NUM_EQ_ERROR,427GAUDI2_IRQ_NUM_USER_FIRST,428GAUDI2_IRQ_NUM_USER_LAST = (GAUDI2_IRQ_NUM_USER_FIRST + GAUDI2_NUM_USER_INTERRUPTS - 1),429GAUDI2_IRQ_NUM_RESERVED_FIRST,430GAUDI2_IRQ_NUM_RESERVED_LAST = (GAUDI2_MSIX_ENTRIES - GAUDI2_NUM_RESERVED_INTERRUPTS - 1),431GAUDI2_IRQ_NUM_UNEXPECTED_ERROR = RESERVED_MSIX_UNEXPECTED_USER_ERROR_INTERRUPT,432GAUDI2_IRQ_NUM_LAST = (GAUDI2_MSIX_ENTRIES - 1)433};434435static_assert(GAUDI2_IRQ_NUM_USER_FIRST > GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM);436437/**438* struct dup_block_ctx - context to initialize unit instances across multiple439* blocks where block can be either a dcore of duplicated440* common module. this code relies on constant offsets441* of blocks and unit instances in a block.442* @instance_cfg_fn: instance specific configuration function.443* @data: private configuration data.444* @base: base address of the first instance in the first block.445* @block_off: subsequent blocks address spacing.446* @instance_off: subsequent block's instances address spacing.447* @enabled_mask: mask of enabled instances (1- enabled, 0- disabled).448* @blocks: number of blocks.449* @instances: unit instances per block.450*/451struct dup_block_ctx {452void (*instance_cfg_fn)(struct hl_device *hdev, u64 base, void *data);453void *data;454u64 base;455u64 block_off;456u64 instance_off;457u64 enabled_mask;458unsigned int blocks;459unsigned int instances;460};461462/**463* struct gaudi2_queues_test_info - Holds the address of a the messages used for testing the464* device queues.465* @dma_addr: the address used by the HW for accessing the message.466* @kern_addr: The address used by the driver for accessing the message.467*/468struct gaudi2_queues_test_info {469dma_addr_t dma_addr;470void *kern_addr;471};472473/**474* struct gaudi2_device - ASIC specific manage structure.475* @cpucp_info_get: get information on device from CPU-CP476* @mapped_blocks: array that holds the base address and size of all blocks477* the user can map.478* @lfsr_rand_seeds: array of MME ACC random seeds to set.479* @hw_queues_lock: protects the H/W queues from concurrent access.480* @scratchpad_kernel_address: general purpose PAGE_SIZE contiguous memory,481* this memory region should be write-only.482* currently used for HBW QMAN writes which is483* redundant.484* @scratchpad_bus_address: scratchpad bus address485* @virt_msix_db_cpu_addr: host memory page for the virtual MSI-X doorbell.486* @virt_msix_db_dma_addr: bus address of the page for the virtual MSI-X doorbell.487* @dram_bar_cur_addr: current address of DRAM PCI bar.488* @hw_cap_initialized: This field contains a bit per H/W engine. When that489* engine is initialized, that bit is set by the driver to490* signal we can use this engine in later code paths.491* Each bit is cleared upon reset of its corresponding H/W492* engine.493* @active_hw_arc: This field contains a bit per ARC of an H/W engine with494* exception of TPC and NIC engines. Once an engine arc is495* initialized, its respective bit is set. Driver can uniquely496* identify each initialized ARC and use this information in497* later code paths. Each respective bit is cleared upon reset498* of its corresponding ARC of the H/W engine.499* @dec_hw_cap_initialized: This field contains a bit per decoder H/W engine.500* When that engine is initialized, that bit is set by501* the driver to signal we can use this engine in later502* code paths.503* Each bit is cleared upon reset of its corresponding H/W504* engine.505* @tpc_hw_cap_initialized: This field contains a bit per TPC H/W engine.506* When that engine is initialized, that bit is set by507* the driver to signal we can use this engine in later508* code paths.509* Each bit is cleared upon reset of its corresponding H/W510* engine.511* @active_tpc_arc: This field contains a bit per ARC of the TPC engines.512* Once an engine arc is initialized, its respective bit is513* set. Each respective bit is cleared upon reset of its514* corresponding ARC of the TPC engine.515* @nic_hw_cap_initialized: This field contains a bit per nic H/W engine.516* @active_nic_arc: This field contains a bit per ARC of the NIC engines.517* Once an engine arc is initialized, its respective bit is518* set. Each respective bit is cleared upon reset of its519* corresponding ARC of the NIC engine.520* @hw_events: array that holds all H/W events that are defined valid.521* @events_stat: array that holds histogram of all received events.522* @events_stat_aggregate: same as events_stat but doesn't get cleared on reset.523* @num_of_valid_hw_events: used to hold the number of valid H/W events.524* @nic_ports: array that holds all NIC ports manage structures.525* @nic_macros: array that holds all NIC macro manage structures.526* @core_info: core info to be used by the Ethernet driver.527* @aux_ops: functions for core <-> aux drivers communication.528* @flush_db_fifo: flag to force flush DB FIFO after a write.529* @hbm_cfg: HBM subsystem settings530* @hw_queues_lock_mutex: used by simulator instead of hw_queues_lock.531* @queues_test_info: information used by the driver when testing the HW queues.532*/533struct gaudi2_device {534int (*cpucp_info_get)(struct hl_device *hdev);535536struct user_mapped_block mapped_blocks[NUM_USER_MAPPED_BLOCKS];537int lfsr_rand_seeds[MME_NUM_OF_LFSR_SEEDS];538539spinlock_t hw_queues_lock;540541void *scratchpad_kernel_address;542dma_addr_t scratchpad_bus_address;543544void *virt_msix_db_cpu_addr;545dma_addr_t virt_msix_db_dma_addr;546547u64 dram_bar_cur_addr;548u64 hw_cap_initialized;549u64 active_hw_arc;550u64 dec_hw_cap_initialized;551u64 tpc_hw_cap_initialized;552u64 active_tpc_arc;553u64 nic_hw_cap_initialized;554u64 active_nic_arc;555u32 hw_events[GAUDI2_EVENT_SIZE];556u32 events_stat[GAUDI2_EVENT_SIZE];557u32 events_stat_aggregate[GAUDI2_EVENT_SIZE];558u32 num_of_valid_hw_events;559560/* Queue testing */561struct gaudi2_queues_test_info queues_test_info[GAUDI2_NUM_TESTED_QS];562};563564/*565* Types of the Gaudi2 IP blocks, used by special blocks iterator.566* Required for scenarios where only particular block types can be567* addressed (e.g., special PLDM images).568*/569enum gaudi2_block_types {570GAUDI2_BLOCK_TYPE_PLL,571GAUDI2_BLOCK_TYPE_RTR,572GAUDI2_BLOCK_TYPE_CPU,573GAUDI2_BLOCK_TYPE_HIF,574GAUDI2_BLOCK_TYPE_HBM,575GAUDI2_BLOCK_TYPE_NIC,576GAUDI2_BLOCK_TYPE_PCIE,577GAUDI2_BLOCK_TYPE_PCIE_PMA,578GAUDI2_BLOCK_TYPE_PDMA,579GAUDI2_BLOCK_TYPE_EDMA,580GAUDI2_BLOCK_TYPE_PMMU,581GAUDI2_BLOCK_TYPE_PSOC,582GAUDI2_BLOCK_TYPE_ROT,583GAUDI2_BLOCK_TYPE_ARC_FARM,584GAUDI2_BLOCK_TYPE_DEC,585GAUDI2_BLOCK_TYPE_MME,586GAUDI2_BLOCK_TYPE_EU_BIST,587GAUDI2_BLOCK_TYPE_SYNC_MNGR,588GAUDI2_BLOCK_TYPE_STLB,589GAUDI2_BLOCK_TYPE_TPC,590GAUDI2_BLOCK_TYPE_HMMU,591GAUDI2_BLOCK_TYPE_SRAM,592GAUDI2_BLOCK_TYPE_XBAR,593GAUDI2_BLOCK_TYPE_KDMA,594GAUDI2_BLOCK_TYPE_XDMA,595GAUDI2_BLOCK_TYPE_XFT,596GAUDI2_BLOCK_TYPE_MAX597};598599extern const u32 gaudi2_dma_core_blocks_bases[DMA_CORE_ID_SIZE];600extern const u32 gaudi2_qm_blocks_bases[GAUDI2_QUEUE_ID_SIZE];601extern const u32 gaudi2_mme_acc_blocks_bases[MME_ID_SIZE];602extern const u32 gaudi2_mme_ctrl_lo_blocks_bases[MME_ID_SIZE];603extern const u32 edma_stream_base[NUM_OF_EDMA_PER_DCORE * NUM_OF_DCORES];604extern const u32 gaudi2_rot_blocks_bases[ROTATOR_ID_SIZE];605606void gaudi2_iterate_tpcs(struct hl_device *hdev, struct iterate_module_ctx *ctx);607int gaudi2_coresight_init(struct hl_device *hdev);608int gaudi2_debug_coresight(struct hl_device *hdev, struct hl_ctx *ctx, void *data);609void gaudi2_halt_coresight(struct hl_device *hdev, struct hl_ctx *ctx);610void gaudi2_init_blocks(struct hl_device *hdev, struct dup_block_ctx *cfg_ctx);611bool gaudi2_is_hmmu_enabled(struct hl_device *hdev, int dcore_id, int hmmu_id);612void gaudi2_write_rr_to_all_lbw_rtrs(struct hl_device *hdev, u8 rr_type, u32 rr_index, u64 min_val,613u64 max_val);614void gaudi2_pb_print_security_errors(struct hl_device *hdev, u32 block_addr, u32 cause,615u32 offended_addr);616int gaudi2_init_security(struct hl_device *hdev);617void gaudi2_ack_protection_bits_errors(struct hl_device *hdev);618int gaudi2_send_device_activity(struct hl_device *hdev, bool open);619620#endif /* GAUDI2P_H_ */621622623