162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci *
362306a36Sopenharmony_ci * Copyright 2019-2022 HabanaLabs, Ltd.
462306a36Sopenharmony_ci * All Rights Reserved.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#ifndef GAUDIP_H_
962306a36Sopenharmony_ci#define GAUDIP_H_
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include <uapi/drm/habanalabs_accel.h>
1262306a36Sopenharmony_ci#include "../common/habanalabs.h"
1362306a36Sopenharmony_ci#include "../include/common/hl_boot_if.h"
1462306a36Sopenharmony_ci#include "../include/gaudi/gaudi_packets.h"
1562306a36Sopenharmony_ci#include "../include/gaudi/gaudi.h"
1662306a36Sopenharmony_ci#include "../include/gaudi/gaudi_async_events.h"
1762306a36Sopenharmony_ci#include "../include/gaudi/gaudi_fw_if.h"
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#define NUMBER_OF_EXT_HW_QUEUES		8
2062306a36Sopenharmony_ci#define NUMBER_OF_CMPLT_QUEUES		NUMBER_OF_EXT_HW_QUEUES
2162306a36Sopenharmony_ci#define NUMBER_OF_CPU_HW_QUEUES		1
2262306a36Sopenharmony_ci#define NUMBER_OF_INT_HW_QUEUES		100
2362306a36Sopenharmony_ci#define NUMBER_OF_HW_QUEUES		(NUMBER_OF_EXT_HW_QUEUES + \
2462306a36Sopenharmony_ci					NUMBER_OF_CPU_HW_QUEUES + \
2562306a36Sopenharmony_ci					NUMBER_OF_INT_HW_QUEUES)
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci/* 10 NIC QMANs, DMA5 QMAN, TPC7 QMAN */
2862306a36Sopenharmony_ci#define NUMBER_OF_COLLECTIVE_QUEUES	12
2962306a36Sopenharmony_ci#define NUMBER_OF_SOBS_IN_GRP		11
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#define GAUDI_STREAM_MASTER_ARR_SIZE	8
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#define CORESIGHT_TIMEOUT_USEC		100000		/* 100 ms */
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci#define GAUDI_MAX_CLK_FREQ		2200000000ull	/* 2200 MHz */
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#define MAX_POWER_DEFAULT_PCI		200000		/* 200W */
3862306a36Sopenharmony_ci#define MAX_POWER_DEFAULT_PMC		350000		/* 350W */
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci#define DC_POWER_DEFAULT_PCI		60000		/* 60W */
4162306a36Sopenharmony_ci#define DC_POWER_DEFAULT_PMC		60000		/* 60W */
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci#define DC_POWER_DEFAULT_PMC_SEC	97000		/* 97W */
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci#define GAUDI_CPU_TIMEOUT_USEC		30000000	/* 30s */
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci#define TPC_ENABLED_MASK		0xFF
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci#define GAUDI_HBM_SIZE_32GB		0x800000000ull
5062306a36Sopenharmony_ci#define GAUDI_HBM_DEVICES		4
5162306a36Sopenharmony_ci#define GAUDI_HBM_CHANNELS		8
5262306a36Sopenharmony_ci#define GAUDI_HBM_CFG_BASE		(mmHBM0_BASE - CFG_BASE)
5362306a36Sopenharmony_ci#define GAUDI_HBM_CFG_OFFSET		(mmHBM1_BASE - mmHBM0_BASE)
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci#define DMA_MAX_TRANSFER_SIZE		U32_MAX
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci#define GAUDI_DEFAULT_CARD_NAME		"HL205"
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci#define GAUDI_MAX_PENDING_CS		SZ_16K
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci#if !IS_MAX_PENDING_CS_VALID(GAUDI_MAX_PENDING_CS)
6262306a36Sopenharmony_ci#error "GAUDI_MAX_PENDING_CS must be power of 2 and greater than 1"
6362306a36Sopenharmony_ci#endif
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci#define PCI_DMA_NUMBER_OF_CHNLS		2
6662306a36Sopenharmony_ci#define HBM_DMA_NUMBER_OF_CHNLS		6
6762306a36Sopenharmony_ci#define DMA_NUMBER_OF_CHNLS		(PCI_DMA_NUMBER_OF_CHNLS + \
6862306a36Sopenharmony_ci						HBM_DMA_NUMBER_OF_CHNLS)
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci#define MME_NUMBER_OF_SLAVE_ENGINES	2
7162306a36Sopenharmony_ci#define MME_NUMBER_OF_ENGINES		(MME_NUMBER_OF_MASTER_ENGINES + \
7262306a36Sopenharmony_ci					MME_NUMBER_OF_SLAVE_ENGINES)
7362306a36Sopenharmony_ci#define MME_NUMBER_OF_QMANS		(MME_NUMBER_OF_MASTER_ENGINES * \
7462306a36Sopenharmony_ci					QMAN_STREAMS)
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci#define QMAN_STREAMS		4
7762306a36Sopenharmony_ci#define PQ_FETCHER_CACHE_SIZE	8
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci#define DMA_QMAN_OFFSET		(mmDMA1_QM_BASE - mmDMA0_QM_BASE)
8062306a36Sopenharmony_ci#define TPC_QMAN_OFFSET		(mmTPC1_QM_BASE - mmTPC0_QM_BASE)
8162306a36Sopenharmony_ci#define MME_QMAN_OFFSET		(mmMME1_QM_BASE - mmMME0_QM_BASE)
8262306a36Sopenharmony_ci#define NIC_MACRO_QMAN_OFFSET	(mmNIC1_QM0_BASE - mmNIC0_QM0_BASE)
8362306a36Sopenharmony_ci#define NIC_ENGINE_QMAN_OFFSET	(mmNIC0_QM1_BASE - mmNIC0_QM0_BASE)
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci#define TPC_CFG_OFFSET		(mmTPC1_CFG_BASE - mmTPC0_CFG_BASE)
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci#define DMA_CORE_OFFSET		(mmDMA1_CORE_BASE - mmDMA0_CORE_BASE)
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci#define QMAN_LDMA_SRC_OFFSET	(mmDMA0_CORE_SRC_BASE_LO - mmDMA0_CORE_CFG_0)
9062306a36Sopenharmony_ci#define QMAN_LDMA_DST_OFFSET	(mmDMA0_CORE_DST_BASE_LO - mmDMA0_CORE_CFG_0)
9162306a36Sopenharmony_ci#define QMAN_LDMA_SIZE_OFFSET	(mmDMA0_CORE_DST_TSIZE_0 - mmDMA0_CORE_CFG_0)
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci#define QMAN_CPDMA_SRC_OFFSET	(mmDMA0_QM_CQ_PTR_LO_4 - mmDMA0_CORE_CFG_0)
9462306a36Sopenharmony_ci#define QMAN_CPDMA_DST_OFFSET	(mmDMA0_CORE_DST_BASE_LO - mmDMA0_CORE_CFG_0)
9562306a36Sopenharmony_ci#define QMAN_CPDMA_SIZE_OFFSET	(mmDMA0_QM_CQ_TSIZE_4 - mmDMA0_CORE_CFG_0)
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci#define SIF_RTR_CTRL_OFFSET	(mmSIF_RTR_CTRL_1_BASE - mmSIF_RTR_CTRL_0_BASE)
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci#define NIF_RTR_CTRL_OFFSET	(mmNIF_RTR_CTRL_1_BASE - mmNIF_RTR_CTRL_0_BASE)
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci#define MME_ACC_OFFSET		(mmMME1_ACC_BASE - mmMME0_ACC_BASE)
10262306a36Sopenharmony_ci#define SRAM_BANK_OFFSET	(mmSRAM_Y0_X1_RTR_BASE - mmSRAM_Y0_X0_RTR_BASE)
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci#define NUM_OF_SOB_IN_BLOCK		\
10562306a36Sopenharmony_ci	(((mmSYNC_MNGR_E_N_SYNC_MNGR_OBJS_SOB_OBJ_2047 - \
10662306a36Sopenharmony_ci	mmSYNC_MNGR_E_N_SYNC_MNGR_OBJS_SOB_OBJ_0) + 4) >> 2)
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ci#define NUM_OF_MONITORS_IN_BLOCK	\
10962306a36Sopenharmony_ci	(((mmSYNC_MNGR_E_N_SYNC_MNGR_OBJS_MON_STATUS_511 - \
11062306a36Sopenharmony_ci	mmSYNC_MNGR_E_N_SYNC_MNGR_OBJS_MON_STATUS_0) + 4) >> 2)
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci#define MONITOR_MAX_SOBS	8
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci/* DRAM Memory Map */
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci#define CPU_FW_IMAGE_SIZE	0x10000000	/* 256MB */
11762306a36Sopenharmony_ci#define MMU_PAGE_TABLES_SIZE	0x0BF00000	/* 191MB */
11862306a36Sopenharmony_ci#define MMU_CACHE_MNG_SIZE	0x00100000	/* 1MB */
11962306a36Sopenharmony_ci#define RESERVED		0x04000000	/* 64MB */
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci#define CPU_FW_IMAGE_ADDR	DRAM_PHYS_BASE
12262306a36Sopenharmony_ci#define MMU_PAGE_TABLES_ADDR	(CPU_FW_IMAGE_ADDR + CPU_FW_IMAGE_SIZE)
12362306a36Sopenharmony_ci#define MMU_CACHE_MNG_ADDR	(MMU_PAGE_TABLES_ADDR + MMU_PAGE_TABLES_SIZE)
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci#define DRAM_DRIVER_END_ADDR	(MMU_CACHE_MNG_ADDR + MMU_CACHE_MNG_SIZE +\
12662306a36Sopenharmony_ci								RESERVED)
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci#define DRAM_BASE_ADDR_USER	0x20000000
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ci#if (DRAM_DRIVER_END_ADDR > DRAM_BASE_ADDR_USER)
13162306a36Sopenharmony_ci#error "Driver must reserve no more than 512MB"
13262306a36Sopenharmony_ci#endif
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci/* Internal QMANs PQ sizes */
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci#define MME_QMAN_LENGTH			1024
13762306a36Sopenharmony_ci#define MME_QMAN_SIZE_IN_BYTES		(MME_QMAN_LENGTH * QMAN_PQ_ENTRY_SIZE)
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci#define HBM_DMA_QMAN_LENGTH		4096
14062306a36Sopenharmony_ci#define HBM_DMA_QMAN_SIZE_IN_BYTES	\
14162306a36Sopenharmony_ci				(HBM_DMA_QMAN_LENGTH * QMAN_PQ_ENTRY_SIZE)
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci#define TPC_QMAN_LENGTH			1024
14462306a36Sopenharmony_ci#define TPC_QMAN_SIZE_IN_BYTES		(TPC_QMAN_LENGTH * QMAN_PQ_ENTRY_SIZE)
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci#define NIC_QMAN_LENGTH			4096
14762306a36Sopenharmony_ci#define NIC_QMAN_SIZE_IN_BYTES		(NIC_QMAN_LENGTH * QMAN_PQ_ENTRY_SIZE)
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci#define SRAM_USER_BASE_OFFSET  GAUDI_DRIVER_SRAM_RESERVED_SIZE_FROM_START
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_ci/* Virtual address space */
15362306a36Sopenharmony_ci#define VA_HOST_SPACE_START	0x1000000000000ull	/* 256TB */
15462306a36Sopenharmony_ci#define VA_HOST_SPACE_END	0x3FF8000000000ull	/* 1PB - 512GB */
15562306a36Sopenharmony_ci#define VA_HOST_SPACE_SIZE	(VA_HOST_SPACE_END - \
15662306a36Sopenharmony_ci					VA_HOST_SPACE_START) /* 767TB */
15762306a36Sopenharmony_ci#define HOST_SPACE_INTERNAL_CB_SZ	SZ_2M
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci#define HW_CAP_PLL		BIT(0)
16062306a36Sopenharmony_ci#define HW_CAP_HBM		BIT(1)
16162306a36Sopenharmony_ci#define HW_CAP_MMU		BIT(2)
16262306a36Sopenharmony_ci#define HW_CAP_MME		BIT(3)
16362306a36Sopenharmony_ci#define HW_CAP_CPU		BIT(4)
16462306a36Sopenharmony_ci#define HW_CAP_PCI_DMA		BIT(5)
16562306a36Sopenharmony_ci#define HW_CAP_MSI		BIT(6)
16662306a36Sopenharmony_ci#define HW_CAP_CPU_Q		BIT(7)
16762306a36Sopenharmony_ci#define HW_CAP_HBM_DMA		BIT(8)
16862306a36Sopenharmony_ci#define HW_CAP_SRAM_SCRAMBLER	BIT(10)
16962306a36Sopenharmony_ci#define HW_CAP_HBM_SCRAMBLER	BIT(11)
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_ci#define HW_CAP_NIC0		BIT(14)
17262306a36Sopenharmony_ci#define HW_CAP_NIC1		BIT(15)
17362306a36Sopenharmony_ci#define HW_CAP_NIC2		BIT(16)
17462306a36Sopenharmony_ci#define HW_CAP_NIC3		BIT(17)
17562306a36Sopenharmony_ci#define HW_CAP_NIC4		BIT(18)
17662306a36Sopenharmony_ci#define HW_CAP_NIC5		BIT(19)
17762306a36Sopenharmony_ci#define HW_CAP_NIC6		BIT(20)
17862306a36Sopenharmony_ci#define HW_CAP_NIC7		BIT(21)
17962306a36Sopenharmony_ci#define HW_CAP_NIC8		BIT(22)
18062306a36Sopenharmony_ci#define HW_CAP_NIC9		BIT(23)
18162306a36Sopenharmony_ci#define HW_CAP_NIC_MASK		GENMASK(23, 14)
18262306a36Sopenharmony_ci#define HW_CAP_NIC_SHIFT	14
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ci#define HW_CAP_TPC0		BIT(24)
18562306a36Sopenharmony_ci#define HW_CAP_TPC1		BIT(25)
18662306a36Sopenharmony_ci#define HW_CAP_TPC2		BIT(26)
18762306a36Sopenharmony_ci#define HW_CAP_TPC3		BIT(27)
18862306a36Sopenharmony_ci#define HW_CAP_TPC4		BIT(28)
18962306a36Sopenharmony_ci#define HW_CAP_TPC5		BIT(29)
19062306a36Sopenharmony_ci#define HW_CAP_TPC6		BIT(30)
19162306a36Sopenharmony_ci#define HW_CAP_TPC7		BIT(31)
19262306a36Sopenharmony_ci#define HW_CAP_TPC_MASK		GENMASK(31, 24)
19362306a36Sopenharmony_ci#define HW_CAP_TPC_SHIFT	24
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_ci#define NEXT_SYNC_OBJ_ADDR_INTERVAL \
19662306a36Sopenharmony_ci	(mmSYNC_MNGR_W_N_SYNC_MNGR_OBJS_SOB_OBJ_0 - \
19762306a36Sopenharmony_ci	 mmSYNC_MNGR_E_N_SYNC_MNGR_OBJS_SOB_OBJ_0)
19862306a36Sopenharmony_ci#define NUM_OF_MME_ENGINES			2
19962306a36Sopenharmony_ci#define NUM_OF_MME_SUB_ENGINES		2
20062306a36Sopenharmony_ci#define NUM_OF_TPC_ENGINES			8
20162306a36Sopenharmony_ci#define NUM_OF_DMA_ENGINES			8
20262306a36Sopenharmony_ci#define NUM_OF_QUEUES				5
20362306a36Sopenharmony_ci#define NUM_OF_STREAMS				4
20462306a36Sopenharmony_ci#define NUM_OF_FENCES				4
20562306a36Sopenharmony_ci
20662306a36Sopenharmony_ci
20762306a36Sopenharmony_ci#define GAUDI_CPU_PCI_MSB_ADDR(addr)	(((addr) & GENMASK_ULL(49, 39)) >> 39)
20862306a36Sopenharmony_ci#define GAUDI_PCI_TO_CPU_ADDR(addr)			\
20962306a36Sopenharmony_ci	do {						\
21062306a36Sopenharmony_ci		(addr) &= ~GENMASK_ULL(49, 39);		\
21162306a36Sopenharmony_ci		(addr) |= BIT_ULL(39);			\
21262306a36Sopenharmony_ci	} while (0)
21362306a36Sopenharmony_ci#define GAUDI_CPU_TO_PCI_ADDR(addr, extension)		\
21462306a36Sopenharmony_ci	do {						\
21562306a36Sopenharmony_ci		(addr) &= ~GENMASK_ULL(49, 39);		\
21662306a36Sopenharmony_ci		(addr) |= (u64) (extension) << 39;	\
21762306a36Sopenharmony_ci	} while (0)
21862306a36Sopenharmony_ci
21962306a36Sopenharmony_cienum gaudi_dma_channels {
22062306a36Sopenharmony_ci	GAUDI_PCI_DMA_1,
22162306a36Sopenharmony_ci	GAUDI_PCI_DMA_2,
22262306a36Sopenharmony_ci	GAUDI_HBM_DMA_1,
22362306a36Sopenharmony_ci	GAUDI_HBM_DMA_2,
22462306a36Sopenharmony_ci	GAUDI_HBM_DMA_3,
22562306a36Sopenharmony_ci	GAUDI_HBM_DMA_4,
22662306a36Sopenharmony_ci	GAUDI_HBM_DMA_5,
22762306a36Sopenharmony_ci	GAUDI_HBM_DMA_6,
22862306a36Sopenharmony_ci	GAUDI_DMA_MAX
22962306a36Sopenharmony_ci};
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_cienum gaudi_tpc_mask {
23262306a36Sopenharmony_ci	GAUDI_TPC_MASK_TPC0 = 0x01,
23362306a36Sopenharmony_ci	GAUDI_TPC_MASK_TPC1 = 0x02,
23462306a36Sopenharmony_ci	GAUDI_TPC_MASK_TPC2 = 0x04,
23562306a36Sopenharmony_ci	GAUDI_TPC_MASK_TPC3 = 0x08,
23662306a36Sopenharmony_ci	GAUDI_TPC_MASK_TPC4 = 0x10,
23762306a36Sopenharmony_ci	GAUDI_TPC_MASK_TPC5 = 0x20,
23862306a36Sopenharmony_ci	GAUDI_TPC_MASK_TPC6 = 0x40,
23962306a36Sopenharmony_ci	GAUDI_TPC_MASK_TPC7 = 0x80,
24062306a36Sopenharmony_ci	GAUDI_TPC_MASK_ALL = 0xFF
24162306a36Sopenharmony_ci};
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_cienum gaudi_nic_mask {
24462306a36Sopenharmony_ci	GAUDI_NIC_MASK_NIC0 = 0x01,
24562306a36Sopenharmony_ci	GAUDI_NIC_MASK_NIC1 = 0x02,
24662306a36Sopenharmony_ci	GAUDI_NIC_MASK_NIC2 = 0x04,
24762306a36Sopenharmony_ci	GAUDI_NIC_MASK_NIC3 = 0x08,
24862306a36Sopenharmony_ci	GAUDI_NIC_MASK_NIC4 = 0x10,
24962306a36Sopenharmony_ci	GAUDI_NIC_MASK_NIC5 = 0x20,
25062306a36Sopenharmony_ci	GAUDI_NIC_MASK_NIC6 = 0x40,
25162306a36Sopenharmony_ci	GAUDI_NIC_MASK_NIC7 = 0x80,
25262306a36Sopenharmony_ci	GAUDI_NIC_MASK_NIC8 = 0x100,
25362306a36Sopenharmony_ci	GAUDI_NIC_MASK_NIC9 = 0x200,
25462306a36Sopenharmony_ci	GAUDI_NIC_MASK_ALL = 0x3FF
25562306a36Sopenharmony_ci};
25662306a36Sopenharmony_ci
25762306a36Sopenharmony_ci/*
25862306a36Sopenharmony_ci * struct gaudi_hw_sob_group - H/W SOB group info.
25962306a36Sopenharmony_ci * @hdev: habanalabs device structure.
26062306a36Sopenharmony_ci * @kref: refcount of this SOB group. group will reset once refcount is zero.
26162306a36Sopenharmony_ci * @base_sob_id: base sob id of this SOB group.
26262306a36Sopenharmony_ci * @queue_id: id of the queue that waits on this sob group
26362306a36Sopenharmony_ci */
26462306a36Sopenharmony_cistruct gaudi_hw_sob_group {
26562306a36Sopenharmony_ci	struct hl_device	*hdev;
26662306a36Sopenharmony_ci	struct kref		kref;
26762306a36Sopenharmony_ci	u32			base_sob_id;
26862306a36Sopenharmony_ci	u32			queue_id;
26962306a36Sopenharmony_ci};
27062306a36Sopenharmony_ci
27162306a36Sopenharmony_ci#define NUM_SOB_GROUPS (HL_RSVD_SOBS * QMAN_STREAMS)
27262306a36Sopenharmony_ci/**
27362306a36Sopenharmony_ci * struct gaudi_collective_properties -
27462306a36Sopenharmony_ci *     holds all SOB groups and queues info reserved for the collective
27562306a36Sopenharmony_ci * @hw_sob_group: H/W SOB groups.
27662306a36Sopenharmony_ci * @next_sob_group_val: the next value to use for the currently used SOB group.
27762306a36Sopenharmony_ci * @curr_sob_group_idx: the index of the currently used SOB group.
27862306a36Sopenharmony_ci * @mstr_sob_mask: pre-defined masks for collective master monitors
27962306a36Sopenharmony_ci */
28062306a36Sopenharmony_cistruct gaudi_collective_properties {
28162306a36Sopenharmony_ci	struct gaudi_hw_sob_group hw_sob_group[NUM_SOB_GROUPS];
28262306a36Sopenharmony_ci	u16			next_sob_group_val[QMAN_STREAMS];
28362306a36Sopenharmony_ci	u8			curr_sob_group_idx[QMAN_STREAMS];
28462306a36Sopenharmony_ci	u8			mstr_sob_mask[HL_COLLECTIVE_RSVD_MSTR_MONS];
28562306a36Sopenharmony_ci};
28662306a36Sopenharmony_ci
28762306a36Sopenharmony_ci/**
28862306a36Sopenharmony_ci * struct gaudi_internal_qman_info - Internal QMAN information.
28962306a36Sopenharmony_ci * @pq_kernel_addr: Kernel address of the PQ memory area in the host.
29062306a36Sopenharmony_ci * @pq_dma_addr: DMA address of the PQ memory area in the host.
29162306a36Sopenharmony_ci * @pq_size: Size of allocated host memory for PQ.
29262306a36Sopenharmony_ci */
29362306a36Sopenharmony_cistruct gaudi_internal_qman_info {
29462306a36Sopenharmony_ci	void		*pq_kernel_addr;
29562306a36Sopenharmony_ci	dma_addr_t	pq_dma_addr;
29662306a36Sopenharmony_ci	size_t		pq_size;
29762306a36Sopenharmony_ci};
29862306a36Sopenharmony_ci
29962306a36Sopenharmony_ci/**
30062306a36Sopenharmony_ci * struct gaudi_device - ASIC specific manage structure.
30162306a36Sopenharmony_ci * @cpucp_info_get: get information on device from CPU-CP
30262306a36Sopenharmony_ci * @hw_queues_lock: protects the H/W queues from concurrent access.
30362306a36Sopenharmony_ci * @internal_qmans: Internal QMANs information. The array size is larger than
30462306a36Sopenharmony_ci *                  the actual number of internal queues because they are not in
30562306a36Sopenharmony_ci *                  consecutive order.
30662306a36Sopenharmony_ci * @hbm_bar_cur_addr: current address of HBM PCI bar.
30762306a36Sopenharmony_ci * @events: array that holds all event id's
30862306a36Sopenharmony_ci * @events_stat: array that holds histogram of all received events.
30962306a36Sopenharmony_ci * @events_stat_aggregate: same as events_stat but doesn't get cleared on reset
31062306a36Sopenharmony_ci * @hw_cap_initialized: This field contains a bit per H/W engine. When that
31162306a36Sopenharmony_ci *                      engine is initialized, that bit is set by the driver to
31262306a36Sopenharmony_ci *                      signal we can use this engine in later code paths.
31362306a36Sopenharmony_ci *                      Each bit is cleared upon reset of its corresponding H/W
31462306a36Sopenharmony_ci *                      engine.
31562306a36Sopenharmony_ci * @mmu_cache_inv_pi: PI for MMU cache invalidation flow. The H/W expects an
31662306a36Sopenharmony_ci *                    8-bit value so use u8.
31762306a36Sopenharmony_ci */
31862306a36Sopenharmony_cistruct gaudi_device {
31962306a36Sopenharmony_ci	int (*cpucp_info_get)(struct hl_device *hdev);
32062306a36Sopenharmony_ci
32162306a36Sopenharmony_ci	/* TODO: remove hw_queues_lock after moving to scheduler code */
32262306a36Sopenharmony_ci	spinlock_t			hw_queues_lock;
32362306a36Sopenharmony_ci
32462306a36Sopenharmony_ci	struct gaudi_internal_qman_info	internal_qmans[GAUDI_QUEUE_ID_SIZE];
32562306a36Sopenharmony_ci
32662306a36Sopenharmony_ci	struct gaudi_collective_properties collective_props;
32762306a36Sopenharmony_ci
32862306a36Sopenharmony_ci	u64				hbm_bar_cur_addr;
32962306a36Sopenharmony_ci
33062306a36Sopenharmony_ci	u32				events[GAUDI_EVENT_SIZE];
33162306a36Sopenharmony_ci	u32				events_stat[GAUDI_EVENT_SIZE];
33262306a36Sopenharmony_ci	u32				events_stat_aggregate[GAUDI_EVENT_SIZE];
33362306a36Sopenharmony_ci	u32				hw_cap_initialized;
33462306a36Sopenharmony_ci	u8				mmu_cache_inv_pi;
33562306a36Sopenharmony_ci};
33662306a36Sopenharmony_ci
33762306a36Sopenharmony_civoid gaudi_init_security(struct hl_device *hdev);
33862306a36Sopenharmony_civoid gaudi_ack_protection_bits_errors(struct hl_device *hdev);
33962306a36Sopenharmony_ciint gaudi_debug_coresight(struct hl_device *hdev, struct hl_ctx *ctx, void *data);
34062306a36Sopenharmony_civoid gaudi_halt_coresight(struct hl_device *hdev, struct hl_ctx *ctx);
34162306a36Sopenharmony_civoid gaudi_mmu_prepare_reg(struct hl_device *hdev, u64 reg, u32 asid);
34262306a36Sopenharmony_ci
34362306a36Sopenharmony_ci#endif /* GAUDIP_H_ */
344