/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note1*2* Copyright 2016-2023 HabanaLabs, Ltd.3* All Rights Reserved.4*5*/67#ifndef HABANALABS_H_8#define HABANALABS_H_910#include <drm/drm.h>1112/*13* Defines that are asic-specific but constitutes as ABI between kernel driver14* and userspace15*/16#define GOYA_KMD_SRAM_RESERVED_SIZE_FROM_START 0x8000 /* 32KB */17#define GAUDI_DRIVER_SRAM_RESERVED_SIZE_FROM_START 0x80 /* 128 bytes */1819/*20* 128 SOBs reserved for collective wait21* 16 SOBs reserved for sync stream22*/23#define GAUDI_FIRST_AVAILABLE_W_S_SYNC_OBJECT 1442425/*26* 64 monitors reserved for collective wait27* 8 monitors reserved for sync stream28*/29#define GAUDI_FIRST_AVAILABLE_W_S_MONITOR 723031/* Max number of elements in timestamps registration buffers */32#define TS_MAX_ELEMENTS_NUM (1 << 20) /* 1MB */3334/*35* Goya queue Numbering36*37* The external queues (PCI DMA channels) MUST be before the internal queues38* and each group (PCI DMA channels and internal) must be contiguous inside39* itself but there can be a gap between the two groups (although not40* recommended)41*/4243enum goya_queue_id {44GOYA_QUEUE_ID_DMA_0 = 0,45GOYA_QUEUE_ID_DMA_1 = 1,46GOYA_QUEUE_ID_DMA_2 = 2,47GOYA_QUEUE_ID_DMA_3 = 3,48GOYA_QUEUE_ID_DMA_4 = 4,49GOYA_QUEUE_ID_CPU_PQ = 5,50GOYA_QUEUE_ID_MME = 6, /* Internal queues start here */51GOYA_QUEUE_ID_TPC0 = 7,52GOYA_QUEUE_ID_TPC1 = 8,53GOYA_QUEUE_ID_TPC2 = 9,54GOYA_QUEUE_ID_TPC3 = 10,55GOYA_QUEUE_ID_TPC4 = 11,56GOYA_QUEUE_ID_TPC5 = 12,57GOYA_QUEUE_ID_TPC6 = 13,58GOYA_QUEUE_ID_TPC7 = 14,59GOYA_QUEUE_ID_SIZE60};6162/*63* Gaudi queue Numbering64* External queues (PCI DMA channels) are DMA_0_*, DMA_1_* and DMA_5_*.65* Except one CPU queue, all the rest are internal queues.66*/6768enum gaudi_queue_id {69GAUDI_QUEUE_ID_DMA_0_0 = 0, /* external */70GAUDI_QUEUE_ID_DMA_0_1 = 1, /* external */71GAUDI_QUEUE_ID_DMA_0_2 = 2, /* external */72GAUDI_QUEUE_ID_DMA_0_3 = 3, /* external */73GAUDI_QUEUE_ID_DMA_1_0 = 4, /* external */74GAUDI_QUEUE_ID_DMA_1_1 = 5, /* external */75GAUDI_QUEUE_ID_DMA_1_2 = 6, /* external */76GAUDI_QUEUE_ID_DMA_1_3 = 7, /* external */77GAUDI_QUEUE_ID_CPU_PQ = 8, /* CPU */78GAUDI_QUEUE_ID_DMA_2_0 = 9, /* internal */79GAUDI_QUEUE_ID_DMA_2_1 = 10, /* internal */80GAUDI_QUEUE_ID_DMA_2_2 = 11, /* internal */81GAUDI_QUEUE_ID_DMA_2_3 = 12, /* internal */82GAUDI_QUEUE_ID_DMA_3_0 = 13, /* internal */83GAUDI_QUEUE_ID_DMA_3_1 = 14, /* internal */84GAUDI_QUEUE_ID_DMA_3_2 = 15, /* internal */85GAUDI_QUEUE_ID_DMA_3_3 = 16, /* internal */86GAUDI_QUEUE_ID_DMA_4_0 = 17, /* internal */87GAUDI_QUEUE_ID_DMA_4_1 = 18, /* internal */88GAUDI_QUEUE_ID_DMA_4_2 = 19, /* internal */89GAUDI_QUEUE_ID_DMA_4_3 = 20, /* internal */90GAUDI_QUEUE_ID_DMA_5_0 = 21, /* internal */91GAUDI_QUEUE_ID_DMA_5_1 = 22, /* internal */92GAUDI_QUEUE_ID_DMA_5_2 = 23, /* internal */93GAUDI_QUEUE_ID_DMA_5_3 = 24, /* internal */94GAUDI_QUEUE_ID_DMA_6_0 = 25, /* internal */95GAUDI_QUEUE_ID_DMA_6_1 = 26, /* internal */96GAUDI_QUEUE_ID_DMA_6_2 = 27, /* internal */97GAUDI_QUEUE_ID_DMA_6_3 = 28, /* internal */98GAUDI_QUEUE_ID_DMA_7_0 = 29, /* internal */99GAUDI_QUEUE_ID_DMA_7_1 = 30, /* internal */100GAUDI_QUEUE_ID_DMA_7_2 = 31, /* internal */101GAUDI_QUEUE_ID_DMA_7_3 = 32, /* internal */102GAUDI_QUEUE_ID_MME_0_0 = 33, /* internal */103GAUDI_QUEUE_ID_MME_0_1 = 34, /* internal */104GAUDI_QUEUE_ID_MME_0_2 = 35, /* internal */105GAUDI_QUEUE_ID_MME_0_3 = 36, /* internal */106GAUDI_QUEUE_ID_MME_1_0 = 37, /* internal */107GAUDI_QUEUE_ID_MME_1_1 = 38, /* internal */108GAUDI_QUEUE_ID_MME_1_2 = 39, /* internal */109GAUDI_QUEUE_ID_MME_1_3 = 40, /* internal */110GAUDI_QUEUE_ID_TPC_0_0 = 41, /* internal */111GAUDI_QUEUE_ID_TPC_0_1 = 42, /* internal */112GAUDI_QUEUE_ID_TPC_0_2 = 43, /* internal */113GAUDI_QUEUE_ID_TPC_0_3 = 44, /* internal */114GAUDI_QUEUE_ID_TPC_1_0 = 45, /* internal */115GAUDI_QUEUE_ID_TPC_1_1 = 46, /* internal */116GAUDI_QUEUE_ID_TPC_1_2 = 47, /* internal */117GAUDI_QUEUE_ID_TPC_1_3 = 48, /* internal */118GAUDI_QUEUE_ID_TPC_2_0 = 49, /* internal */119GAUDI_QUEUE_ID_TPC_2_1 = 50, /* internal */120GAUDI_QUEUE_ID_TPC_2_2 = 51, /* internal */121GAUDI_QUEUE_ID_TPC_2_3 = 52, /* internal */122GAUDI_QUEUE_ID_TPC_3_0 = 53, /* internal */123GAUDI_QUEUE_ID_TPC_3_1 = 54, /* internal */124GAUDI_QUEUE_ID_TPC_3_2 = 55, /* internal */125GAUDI_QUEUE_ID_TPC_3_3 = 56, /* internal */126GAUDI_QUEUE_ID_TPC_4_0 = 57, /* internal */127GAUDI_QUEUE_ID_TPC_4_1 = 58, /* internal */128GAUDI_QUEUE_ID_TPC_4_2 = 59, /* internal */129GAUDI_QUEUE_ID_TPC_4_3 = 60, /* internal */130GAUDI_QUEUE_ID_TPC_5_0 = 61, /* internal */131GAUDI_QUEUE_ID_TPC_5_1 = 62, /* internal */132GAUDI_QUEUE_ID_TPC_5_2 = 63, /* internal */133GAUDI_QUEUE_ID_TPC_5_3 = 64, /* internal */134GAUDI_QUEUE_ID_TPC_6_0 = 65, /* internal */135GAUDI_QUEUE_ID_TPC_6_1 = 66, /* internal */136GAUDI_QUEUE_ID_TPC_6_2 = 67, /* internal */137GAUDI_QUEUE_ID_TPC_6_3 = 68, /* internal */138GAUDI_QUEUE_ID_TPC_7_0 = 69, /* internal */139GAUDI_QUEUE_ID_TPC_7_1 = 70, /* internal */140GAUDI_QUEUE_ID_TPC_7_2 = 71, /* internal */141GAUDI_QUEUE_ID_TPC_7_3 = 72, /* internal */142GAUDI_QUEUE_ID_NIC_0_0 = 73, /* internal */143GAUDI_QUEUE_ID_NIC_0_1 = 74, /* internal */144GAUDI_QUEUE_ID_NIC_0_2 = 75, /* internal */145GAUDI_QUEUE_ID_NIC_0_3 = 76, /* internal */146GAUDI_QUEUE_ID_NIC_1_0 = 77, /* internal */147GAUDI_QUEUE_ID_NIC_1_1 = 78, /* internal */148GAUDI_QUEUE_ID_NIC_1_2 = 79, /* internal */149GAUDI_QUEUE_ID_NIC_1_3 = 80, /* internal */150GAUDI_QUEUE_ID_NIC_2_0 = 81, /* internal */151GAUDI_QUEUE_ID_NIC_2_1 = 82, /* internal */152GAUDI_QUEUE_ID_NIC_2_2 = 83, /* internal */153GAUDI_QUEUE_ID_NIC_2_3 = 84, /* internal */154GAUDI_QUEUE_ID_NIC_3_0 = 85, /* internal */155GAUDI_QUEUE_ID_NIC_3_1 = 86, /* internal */156GAUDI_QUEUE_ID_NIC_3_2 = 87, /* internal */157GAUDI_QUEUE_ID_NIC_3_3 = 88, /* internal */158GAUDI_QUEUE_ID_NIC_4_0 = 89, /* internal */159GAUDI_QUEUE_ID_NIC_4_1 = 90, /* internal */160GAUDI_QUEUE_ID_NIC_4_2 = 91, /* internal */161GAUDI_QUEUE_ID_NIC_4_3 = 92, /* internal */162GAUDI_QUEUE_ID_NIC_5_0 = 93, /* internal */163GAUDI_QUEUE_ID_NIC_5_1 = 94, /* internal */164GAUDI_QUEUE_ID_NIC_5_2 = 95, /* internal */165GAUDI_QUEUE_ID_NIC_5_3 = 96, /* internal */166GAUDI_QUEUE_ID_NIC_6_0 = 97, /* internal */167GAUDI_QUEUE_ID_NIC_6_1 = 98, /* internal */168GAUDI_QUEUE_ID_NIC_6_2 = 99, /* internal */169GAUDI_QUEUE_ID_NIC_6_3 = 100, /* internal */170GAUDI_QUEUE_ID_NIC_7_0 = 101, /* internal */171GAUDI_QUEUE_ID_NIC_7_1 = 102, /* internal */172GAUDI_QUEUE_ID_NIC_7_2 = 103, /* internal */173GAUDI_QUEUE_ID_NIC_7_3 = 104, /* internal */174GAUDI_QUEUE_ID_NIC_8_0 = 105, /* internal */175GAUDI_QUEUE_ID_NIC_8_1 = 106, /* internal */176GAUDI_QUEUE_ID_NIC_8_2 = 107, /* internal */177GAUDI_QUEUE_ID_NIC_8_3 = 108, /* internal */178GAUDI_QUEUE_ID_NIC_9_0 = 109, /* internal */179GAUDI_QUEUE_ID_NIC_9_1 = 110, /* internal */180GAUDI_QUEUE_ID_NIC_9_2 = 111, /* internal */181GAUDI_QUEUE_ID_NIC_9_3 = 112, /* internal */182GAUDI_QUEUE_ID_SIZE183};184185/*186* In GAUDI2 we have two modes of operation in regard to queues:187* 1. Legacy mode, where each QMAN exposes 4 streams to the user188* 2. F/W mode, where we use F/W to schedule the JOBS to the different queues.189*190* When in legacy mode, the user sends the queue id per JOB according to191* enum gaudi2_queue_id below.192*193* When in F/W mode, the user sends a stream id per Command Submission. The194* stream id is a running number from 0 up to (N-1), where N is the number195* of streams the F/W exposes and is passed to the user in196* struct hl_info_hw_ip_info197*/198199enum gaudi2_queue_id {200GAUDI2_QUEUE_ID_PDMA_0_0 = 0,201GAUDI2_QUEUE_ID_PDMA_0_1 = 1,202GAUDI2_QUEUE_ID_PDMA_0_2 = 2,203GAUDI2_QUEUE_ID_PDMA_0_3 = 3,204GAUDI2_QUEUE_ID_PDMA_1_0 = 4,205GAUDI2_QUEUE_ID_PDMA_1_1 = 5,206GAUDI2_QUEUE_ID_PDMA_1_2 = 6,207GAUDI2_QUEUE_ID_PDMA_1_3 = 7,208GAUDI2_QUEUE_ID_DCORE0_EDMA_0_0 = 8,209GAUDI2_QUEUE_ID_DCORE0_EDMA_0_1 = 9,210GAUDI2_QUEUE_ID_DCORE0_EDMA_0_2 = 10,211GAUDI2_QUEUE_ID_DCORE0_EDMA_0_3 = 11,212GAUDI2_QUEUE_ID_DCORE0_EDMA_1_0 = 12,213GAUDI2_QUEUE_ID_DCORE0_EDMA_1_1 = 13,214GAUDI2_QUEUE_ID_DCORE0_EDMA_1_2 = 14,215GAUDI2_QUEUE_ID_DCORE0_EDMA_1_3 = 15,216GAUDI2_QUEUE_ID_DCORE0_MME_0_0 = 16,217GAUDI2_QUEUE_ID_DCORE0_MME_0_1 = 17,218GAUDI2_QUEUE_ID_DCORE0_MME_0_2 = 18,219GAUDI2_QUEUE_ID_DCORE0_MME_0_3 = 19,220GAUDI2_QUEUE_ID_DCORE0_TPC_0_0 = 20,221GAUDI2_QUEUE_ID_DCORE0_TPC_0_1 = 21,222GAUDI2_QUEUE_ID_DCORE0_TPC_0_2 = 22,223GAUDI2_QUEUE_ID_DCORE0_TPC_0_3 = 23,224GAUDI2_QUEUE_ID_DCORE0_TPC_1_0 = 24,225GAUDI2_QUEUE_ID_DCORE0_TPC_1_1 = 25,226GAUDI2_QUEUE_ID_DCORE0_TPC_1_2 = 26,227GAUDI2_QUEUE_ID_DCORE0_TPC_1_3 = 27,228GAUDI2_QUEUE_ID_DCORE0_TPC_2_0 = 28,229GAUDI2_QUEUE_ID_DCORE0_TPC_2_1 = 29,230GAUDI2_QUEUE_ID_DCORE0_TPC_2_2 = 30,231GAUDI2_QUEUE_ID_DCORE0_TPC_2_3 = 31,232GAUDI2_QUEUE_ID_DCORE0_TPC_3_0 = 32,233GAUDI2_QUEUE_ID_DCORE0_TPC_3_1 = 33,234GAUDI2_QUEUE_ID_DCORE0_TPC_3_2 = 34,235GAUDI2_QUEUE_ID_DCORE0_TPC_3_3 = 35,236GAUDI2_QUEUE_ID_DCORE0_TPC_4_0 = 36,237GAUDI2_QUEUE_ID_DCORE0_TPC_4_1 = 37,238GAUDI2_QUEUE_ID_DCORE0_TPC_4_2 = 38,239GAUDI2_QUEUE_ID_DCORE0_TPC_4_3 = 39,240GAUDI2_QUEUE_ID_DCORE0_TPC_5_0 = 40,241GAUDI2_QUEUE_ID_DCORE0_TPC_5_1 = 41,242GAUDI2_QUEUE_ID_DCORE0_TPC_5_2 = 42,243GAUDI2_QUEUE_ID_DCORE0_TPC_5_3 = 43,244GAUDI2_QUEUE_ID_DCORE0_TPC_6_0 = 44,245GAUDI2_QUEUE_ID_DCORE0_TPC_6_1 = 45,246GAUDI2_QUEUE_ID_DCORE0_TPC_6_2 = 46,247GAUDI2_QUEUE_ID_DCORE0_TPC_6_3 = 47,248GAUDI2_QUEUE_ID_DCORE1_EDMA_0_0 = 48,249GAUDI2_QUEUE_ID_DCORE1_EDMA_0_1 = 49,250GAUDI2_QUEUE_ID_DCORE1_EDMA_0_2 = 50,251GAUDI2_QUEUE_ID_DCORE1_EDMA_0_3 = 51,252GAUDI2_QUEUE_ID_DCORE1_EDMA_1_0 = 52,253GAUDI2_QUEUE_ID_DCORE1_EDMA_1_1 = 53,254GAUDI2_QUEUE_ID_DCORE1_EDMA_1_2 = 54,255GAUDI2_QUEUE_ID_DCORE1_EDMA_1_3 = 55,256GAUDI2_QUEUE_ID_DCORE1_MME_0_0 = 56,257GAUDI2_QUEUE_ID_DCORE1_MME_0_1 = 57,258GAUDI2_QUEUE_ID_DCORE1_MME_0_2 = 58,259GAUDI2_QUEUE_ID_DCORE1_MME_0_3 = 59,260GAUDI2_QUEUE_ID_DCORE1_TPC_0_0 = 60,261GAUDI2_QUEUE_ID_DCORE1_TPC_0_1 = 61,262GAUDI2_QUEUE_ID_DCORE1_TPC_0_2 = 62,263GAUDI2_QUEUE_ID_DCORE1_TPC_0_3 = 63,264GAUDI2_QUEUE_ID_DCORE1_TPC_1_0 = 64,265GAUDI2_QUEUE_ID_DCORE1_TPC_1_1 = 65,266GAUDI2_QUEUE_ID_DCORE1_TPC_1_2 = 66,267GAUDI2_QUEUE_ID_DCORE1_TPC_1_3 = 67,268GAUDI2_QUEUE_ID_DCORE1_TPC_2_0 = 68,269GAUDI2_QUEUE_ID_DCORE1_TPC_2_1 = 69,270GAUDI2_QUEUE_ID_DCORE1_TPC_2_2 = 70,271GAUDI2_QUEUE_ID_DCORE1_TPC_2_3 = 71,272GAUDI2_QUEUE_ID_DCORE1_TPC_3_0 = 72,273GAUDI2_QUEUE_ID_DCORE1_TPC_3_1 = 73,274GAUDI2_QUEUE_ID_DCORE1_TPC_3_2 = 74,275GAUDI2_QUEUE_ID_DCORE1_TPC_3_3 = 75,276GAUDI2_QUEUE_ID_DCORE1_TPC_4_0 = 76,277GAUDI2_QUEUE_ID_DCORE1_TPC_4_1 = 77,278GAUDI2_QUEUE_ID_DCORE1_TPC_4_2 = 78,279GAUDI2_QUEUE_ID_DCORE1_TPC_4_3 = 79,280GAUDI2_QUEUE_ID_DCORE1_TPC_5_0 = 80,281GAUDI2_QUEUE_ID_DCORE1_TPC_5_1 = 81,282GAUDI2_QUEUE_ID_DCORE1_TPC_5_2 = 82,283GAUDI2_QUEUE_ID_DCORE1_TPC_5_3 = 83,284GAUDI2_QUEUE_ID_DCORE2_EDMA_0_0 = 84,285GAUDI2_QUEUE_ID_DCORE2_EDMA_0_1 = 85,286GAUDI2_QUEUE_ID_DCORE2_EDMA_0_2 = 86,287GAUDI2_QUEUE_ID_DCORE2_EDMA_0_3 = 87,288GAUDI2_QUEUE_ID_DCORE2_EDMA_1_0 = 88,289GAUDI2_QUEUE_ID_DCORE2_EDMA_1_1 = 89,290GAUDI2_QUEUE_ID_DCORE2_EDMA_1_2 = 90,291GAUDI2_QUEUE_ID_DCORE2_EDMA_1_3 = 91,292GAUDI2_QUEUE_ID_DCORE2_MME_0_0 = 92,293GAUDI2_QUEUE_ID_DCORE2_MME_0_1 = 93,294GAUDI2_QUEUE_ID_DCORE2_MME_0_2 = 94,295GAUDI2_QUEUE_ID_DCORE2_MME_0_3 = 95,296GAUDI2_QUEUE_ID_DCORE2_TPC_0_0 = 96,297GAUDI2_QUEUE_ID_DCORE2_TPC_0_1 = 97,298GAUDI2_QUEUE_ID_DCORE2_TPC_0_2 = 98,299GAUDI2_QUEUE_ID_DCORE2_TPC_0_3 = 99,300GAUDI2_QUEUE_ID_DCORE2_TPC_1_0 = 100,301GAUDI2_QUEUE_ID_DCORE2_TPC_1_1 = 101,302GAUDI2_QUEUE_ID_DCORE2_TPC_1_2 = 102,303GAUDI2_QUEUE_ID_DCORE2_TPC_1_3 = 103,304GAUDI2_QUEUE_ID_DCORE2_TPC_2_0 = 104,305GAUDI2_QUEUE_ID_DCORE2_TPC_2_1 = 105,306GAUDI2_QUEUE_ID_DCORE2_TPC_2_2 = 106,307GAUDI2_QUEUE_ID_DCORE2_TPC_2_3 = 107,308GAUDI2_QUEUE_ID_DCORE2_TPC_3_0 = 108,309GAUDI2_QUEUE_ID_DCORE2_TPC_3_1 = 109,310GAUDI2_QUEUE_ID_DCORE2_TPC_3_2 = 110,311GAUDI2_QUEUE_ID_DCORE2_TPC_3_3 = 111,312GAUDI2_QUEUE_ID_DCORE2_TPC_4_0 = 112,313GAUDI2_QUEUE_ID_DCORE2_TPC_4_1 = 113,314GAUDI2_QUEUE_ID_DCORE2_TPC_4_2 = 114,315GAUDI2_QUEUE_ID_DCORE2_TPC_4_3 = 115,316GAUDI2_QUEUE_ID_DCORE2_TPC_5_0 = 116,317GAUDI2_QUEUE_ID_DCORE2_TPC_5_1 = 117,318GAUDI2_QUEUE_ID_DCORE2_TPC_5_2 = 118,319GAUDI2_QUEUE_ID_DCORE2_TPC_5_3 = 119,320GAUDI2_QUEUE_ID_DCORE3_EDMA_0_0 = 120,321GAUDI2_QUEUE_ID_DCORE3_EDMA_0_1 = 121,322GAUDI2_QUEUE_ID_DCORE3_EDMA_0_2 = 122,323GAUDI2_QUEUE_ID_DCORE3_EDMA_0_3 = 123,324GAUDI2_QUEUE_ID_DCORE3_EDMA_1_0 = 124,325GAUDI2_QUEUE_ID_DCORE3_EDMA_1_1 = 125,326GAUDI2_QUEUE_ID_DCORE3_EDMA_1_2 = 126,327GAUDI2_QUEUE_ID_DCORE3_EDMA_1_3 = 127,328GAUDI2_QUEUE_ID_DCORE3_MME_0_0 = 128,329GAUDI2_QUEUE_ID_DCORE3_MME_0_1 = 129,330GAUDI2_QUEUE_ID_DCORE3_MME_0_2 = 130,331GAUDI2_QUEUE_ID_DCORE3_MME_0_3 = 131,332GAUDI2_QUEUE_ID_DCORE3_TPC_0_0 = 132,333GAUDI2_QUEUE_ID_DCORE3_TPC_0_1 = 133,334GAUDI2_QUEUE_ID_DCORE3_TPC_0_2 = 134,335GAUDI2_QUEUE_ID_DCORE3_TPC_0_3 = 135,336GAUDI2_QUEUE_ID_DCORE3_TPC_1_0 = 136,337GAUDI2_QUEUE_ID_DCORE3_TPC_1_1 = 137,338GAUDI2_QUEUE_ID_DCORE3_TPC_1_2 = 138,339GAUDI2_QUEUE_ID_DCORE3_TPC_1_3 = 139,340GAUDI2_QUEUE_ID_DCORE3_TPC_2_0 = 140,341GAUDI2_QUEUE_ID_DCORE3_TPC_2_1 = 141,342GAUDI2_QUEUE_ID_DCORE3_TPC_2_2 = 142,343GAUDI2_QUEUE_ID_DCORE3_TPC_2_3 = 143,344GAUDI2_QUEUE_ID_DCORE3_TPC_3_0 = 144,345GAUDI2_QUEUE_ID_DCORE3_TPC_3_1 = 145,346GAUDI2_QUEUE_ID_DCORE3_TPC_3_2 = 146,347GAUDI2_QUEUE_ID_DCORE3_TPC_3_3 = 147,348GAUDI2_QUEUE_ID_DCORE3_TPC_4_0 = 148,349GAUDI2_QUEUE_ID_DCORE3_TPC_4_1 = 149,350GAUDI2_QUEUE_ID_DCORE3_TPC_4_2 = 150,351GAUDI2_QUEUE_ID_DCORE3_TPC_4_3 = 151,352GAUDI2_QUEUE_ID_DCORE3_TPC_5_0 = 152,353GAUDI2_QUEUE_ID_DCORE3_TPC_5_1 = 153,354GAUDI2_QUEUE_ID_DCORE3_TPC_5_2 = 154,355GAUDI2_QUEUE_ID_DCORE3_TPC_5_3 = 155,356GAUDI2_QUEUE_ID_NIC_0_0 = 156,357GAUDI2_QUEUE_ID_NIC_0_1 = 157,358GAUDI2_QUEUE_ID_NIC_0_2 = 158,359GAUDI2_QUEUE_ID_NIC_0_3 = 159,360GAUDI2_QUEUE_ID_NIC_1_0 = 160,361GAUDI2_QUEUE_ID_NIC_1_1 = 161,362GAUDI2_QUEUE_ID_NIC_1_2 = 162,363GAUDI2_QUEUE_ID_NIC_1_3 = 163,364GAUDI2_QUEUE_ID_NIC_2_0 = 164,365GAUDI2_QUEUE_ID_NIC_2_1 = 165,366GAUDI2_QUEUE_ID_NIC_2_2 = 166,367GAUDI2_QUEUE_ID_NIC_2_3 = 167,368GAUDI2_QUEUE_ID_NIC_3_0 = 168,369GAUDI2_QUEUE_ID_NIC_3_1 = 169,370GAUDI2_QUEUE_ID_NIC_3_2 = 170,371GAUDI2_QUEUE_ID_NIC_3_3 = 171,372GAUDI2_QUEUE_ID_NIC_4_0 = 172,373GAUDI2_QUEUE_ID_NIC_4_1 = 173,374GAUDI2_QUEUE_ID_NIC_4_2 = 174,375GAUDI2_QUEUE_ID_NIC_4_3 = 175,376GAUDI2_QUEUE_ID_NIC_5_0 = 176,377GAUDI2_QUEUE_ID_NIC_5_1 = 177,378GAUDI2_QUEUE_ID_NIC_5_2 = 178,379GAUDI2_QUEUE_ID_NIC_5_3 = 179,380GAUDI2_QUEUE_ID_NIC_6_0 = 180,381GAUDI2_QUEUE_ID_NIC_6_1 = 181,382GAUDI2_QUEUE_ID_NIC_6_2 = 182,383GAUDI2_QUEUE_ID_NIC_6_3 = 183,384GAUDI2_QUEUE_ID_NIC_7_0 = 184,385GAUDI2_QUEUE_ID_NIC_7_1 = 185,386GAUDI2_QUEUE_ID_NIC_7_2 = 186,387GAUDI2_QUEUE_ID_NIC_7_3 = 187,388GAUDI2_QUEUE_ID_NIC_8_0 = 188,389GAUDI2_QUEUE_ID_NIC_8_1 = 189,390GAUDI2_QUEUE_ID_NIC_8_2 = 190,391GAUDI2_QUEUE_ID_NIC_8_3 = 191,392GAUDI2_QUEUE_ID_NIC_9_0 = 192,393GAUDI2_QUEUE_ID_NIC_9_1 = 193,394GAUDI2_QUEUE_ID_NIC_9_2 = 194,395GAUDI2_QUEUE_ID_NIC_9_3 = 195,396GAUDI2_QUEUE_ID_NIC_10_0 = 196,397GAUDI2_QUEUE_ID_NIC_10_1 = 197,398GAUDI2_QUEUE_ID_NIC_10_2 = 198,399GAUDI2_QUEUE_ID_NIC_10_3 = 199,400GAUDI2_QUEUE_ID_NIC_11_0 = 200,401GAUDI2_QUEUE_ID_NIC_11_1 = 201,402GAUDI2_QUEUE_ID_NIC_11_2 = 202,403GAUDI2_QUEUE_ID_NIC_11_3 = 203,404GAUDI2_QUEUE_ID_NIC_12_0 = 204,405GAUDI2_QUEUE_ID_NIC_12_1 = 205,406GAUDI2_QUEUE_ID_NIC_12_2 = 206,407GAUDI2_QUEUE_ID_NIC_12_3 = 207,408GAUDI2_QUEUE_ID_NIC_13_0 = 208,409GAUDI2_QUEUE_ID_NIC_13_1 = 209,410GAUDI2_QUEUE_ID_NIC_13_2 = 210,411GAUDI2_QUEUE_ID_NIC_13_3 = 211,412GAUDI2_QUEUE_ID_NIC_14_0 = 212,413GAUDI2_QUEUE_ID_NIC_14_1 = 213,414GAUDI2_QUEUE_ID_NIC_14_2 = 214,415GAUDI2_QUEUE_ID_NIC_14_3 = 215,416GAUDI2_QUEUE_ID_NIC_15_0 = 216,417GAUDI2_QUEUE_ID_NIC_15_1 = 217,418GAUDI2_QUEUE_ID_NIC_15_2 = 218,419GAUDI2_QUEUE_ID_NIC_15_3 = 219,420GAUDI2_QUEUE_ID_NIC_16_0 = 220,421GAUDI2_QUEUE_ID_NIC_16_1 = 221,422GAUDI2_QUEUE_ID_NIC_16_2 = 222,423GAUDI2_QUEUE_ID_NIC_16_3 = 223,424GAUDI2_QUEUE_ID_NIC_17_0 = 224,425GAUDI2_QUEUE_ID_NIC_17_1 = 225,426GAUDI2_QUEUE_ID_NIC_17_2 = 226,427GAUDI2_QUEUE_ID_NIC_17_3 = 227,428GAUDI2_QUEUE_ID_NIC_18_0 = 228,429GAUDI2_QUEUE_ID_NIC_18_1 = 229,430GAUDI2_QUEUE_ID_NIC_18_2 = 230,431GAUDI2_QUEUE_ID_NIC_18_3 = 231,432GAUDI2_QUEUE_ID_NIC_19_0 = 232,433GAUDI2_QUEUE_ID_NIC_19_1 = 233,434GAUDI2_QUEUE_ID_NIC_19_2 = 234,435GAUDI2_QUEUE_ID_NIC_19_3 = 235,436GAUDI2_QUEUE_ID_NIC_20_0 = 236,437GAUDI2_QUEUE_ID_NIC_20_1 = 237,438GAUDI2_QUEUE_ID_NIC_20_2 = 238,439GAUDI2_QUEUE_ID_NIC_20_3 = 239,440GAUDI2_QUEUE_ID_NIC_21_0 = 240,441GAUDI2_QUEUE_ID_NIC_21_1 = 241,442GAUDI2_QUEUE_ID_NIC_21_2 = 242,443GAUDI2_QUEUE_ID_NIC_21_3 = 243,444GAUDI2_QUEUE_ID_NIC_22_0 = 244,445GAUDI2_QUEUE_ID_NIC_22_1 = 245,446GAUDI2_QUEUE_ID_NIC_22_2 = 246,447GAUDI2_QUEUE_ID_NIC_22_3 = 247,448GAUDI2_QUEUE_ID_NIC_23_0 = 248,449GAUDI2_QUEUE_ID_NIC_23_1 = 249,450GAUDI2_QUEUE_ID_NIC_23_2 = 250,451GAUDI2_QUEUE_ID_NIC_23_3 = 251,452GAUDI2_QUEUE_ID_ROT_0_0 = 252,453GAUDI2_QUEUE_ID_ROT_0_1 = 253,454GAUDI2_QUEUE_ID_ROT_0_2 = 254,455GAUDI2_QUEUE_ID_ROT_0_3 = 255,456GAUDI2_QUEUE_ID_ROT_1_0 = 256,457GAUDI2_QUEUE_ID_ROT_1_1 = 257,458GAUDI2_QUEUE_ID_ROT_1_2 = 258,459GAUDI2_QUEUE_ID_ROT_1_3 = 259,460GAUDI2_QUEUE_ID_CPU_PQ = 260,461GAUDI2_QUEUE_ID_SIZE462};463464/*465* Engine Numbering466*467* Used in the "busy_engines_mask" field in `struct hl_info_hw_idle'468*/469470enum goya_engine_id {471GOYA_ENGINE_ID_DMA_0 = 0,472GOYA_ENGINE_ID_DMA_1,473GOYA_ENGINE_ID_DMA_2,474GOYA_ENGINE_ID_DMA_3,475GOYA_ENGINE_ID_DMA_4,476GOYA_ENGINE_ID_MME_0,477GOYA_ENGINE_ID_TPC_0,478GOYA_ENGINE_ID_TPC_1,479GOYA_ENGINE_ID_TPC_2,480GOYA_ENGINE_ID_TPC_3,481GOYA_ENGINE_ID_TPC_4,482GOYA_ENGINE_ID_TPC_5,483GOYA_ENGINE_ID_TPC_6,484GOYA_ENGINE_ID_TPC_7,485GOYA_ENGINE_ID_SIZE486};487488enum gaudi_engine_id {489GAUDI_ENGINE_ID_DMA_0 = 0,490GAUDI_ENGINE_ID_DMA_1,491GAUDI_ENGINE_ID_DMA_2,492GAUDI_ENGINE_ID_DMA_3,493GAUDI_ENGINE_ID_DMA_4,494GAUDI_ENGINE_ID_DMA_5,495GAUDI_ENGINE_ID_DMA_6,496GAUDI_ENGINE_ID_DMA_7,497GAUDI_ENGINE_ID_MME_0,498GAUDI_ENGINE_ID_MME_1,499GAUDI_ENGINE_ID_MME_2,500GAUDI_ENGINE_ID_MME_3,501GAUDI_ENGINE_ID_TPC_0,502GAUDI_ENGINE_ID_TPC_1,503GAUDI_ENGINE_ID_TPC_2,504GAUDI_ENGINE_ID_TPC_3,505GAUDI_ENGINE_ID_TPC_4,506GAUDI_ENGINE_ID_TPC_5,507GAUDI_ENGINE_ID_TPC_6,508GAUDI_ENGINE_ID_TPC_7,509GAUDI_ENGINE_ID_NIC_0,510GAUDI_ENGINE_ID_NIC_1,511GAUDI_ENGINE_ID_NIC_2,512GAUDI_ENGINE_ID_NIC_3,513GAUDI_ENGINE_ID_NIC_4,514GAUDI_ENGINE_ID_NIC_5,515GAUDI_ENGINE_ID_NIC_6,516GAUDI_ENGINE_ID_NIC_7,517GAUDI_ENGINE_ID_NIC_8,518GAUDI_ENGINE_ID_NIC_9,519GAUDI_ENGINE_ID_SIZE520};521522enum gaudi2_engine_id {523GAUDI2_DCORE0_ENGINE_ID_EDMA_0 = 0,524GAUDI2_DCORE0_ENGINE_ID_EDMA_1,525GAUDI2_DCORE0_ENGINE_ID_MME,526GAUDI2_DCORE0_ENGINE_ID_TPC_0,527GAUDI2_DCORE0_ENGINE_ID_TPC_1,528GAUDI2_DCORE0_ENGINE_ID_TPC_2,529GAUDI2_DCORE0_ENGINE_ID_TPC_3,530GAUDI2_DCORE0_ENGINE_ID_TPC_4,531GAUDI2_DCORE0_ENGINE_ID_TPC_5,532GAUDI2_DCORE0_ENGINE_ID_DEC_0,533GAUDI2_DCORE0_ENGINE_ID_DEC_1,534GAUDI2_DCORE1_ENGINE_ID_EDMA_0,535GAUDI2_DCORE1_ENGINE_ID_EDMA_1,536GAUDI2_DCORE1_ENGINE_ID_MME,537GAUDI2_DCORE1_ENGINE_ID_TPC_0,538GAUDI2_DCORE1_ENGINE_ID_TPC_1,539GAUDI2_DCORE1_ENGINE_ID_TPC_2,540GAUDI2_DCORE1_ENGINE_ID_TPC_3,541GAUDI2_DCORE1_ENGINE_ID_TPC_4,542GAUDI2_DCORE1_ENGINE_ID_TPC_5,543GAUDI2_DCORE1_ENGINE_ID_DEC_0,544GAUDI2_DCORE1_ENGINE_ID_DEC_1,545GAUDI2_DCORE2_ENGINE_ID_EDMA_0,546GAUDI2_DCORE2_ENGINE_ID_EDMA_1,547GAUDI2_DCORE2_ENGINE_ID_MME,548GAUDI2_DCORE2_ENGINE_ID_TPC_0,549GAUDI2_DCORE2_ENGINE_ID_TPC_1,550GAUDI2_DCORE2_ENGINE_ID_TPC_2,551GAUDI2_DCORE2_ENGINE_ID_TPC_3,552GAUDI2_DCORE2_ENGINE_ID_TPC_4,553GAUDI2_DCORE2_ENGINE_ID_TPC_5,554GAUDI2_DCORE2_ENGINE_ID_DEC_0,555GAUDI2_DCORE2_ENGINE_ID_DEC_1,556GAUDI2_DCORE3_ENGINE_ID_EDMA_0,557GAUDI2_DCORE3_ENGINE_ID_EDMA_1,558GAUDI2_DCORE3_ENGINE_ID_MME,559GAUDI2_DCORE3_ENGINE_ID_TPC_0,560GAUDI2_DCORE3_ENGINE_ID_TPC_1,561GAUDI2_DCORE3_ENGINE_ID_TPC_2,562GAUDI2_DCORE3_ENGINE_ID_TPC_3,563GAUDI2_DCORE3_ENGINE_ID_TPC_4,564GAUDI2_DCORE3_ENGINE_ID_TPC_5,565GAUDI2_DCORE3_ENGINE_ID_DEC_0,566GAUDI2_DCORE3_ENGINE_ID_DEC_1,567GAUDI2_DCORE0_ENGINE_ID_TPC_6,568GAUDI2_ENGINE_ID_PDMA_0,569GAUDI2_ENGINE_ID_PDMA_1,570GAUDI2_ENGINE_ID_ROT_0,571GAUDI2_ENGINE_ID_ROT_1,572GAUDI2_PCIE_ENGINE_ID_DEC_0,573GAUDI2_PCIE_ENGINE_ID_DEC_1,574GAUDI2_ENGINE_ID_NIC0_0,575GAUDI2_ENGINE_ID_NIC0_1,576GAUDI2_ENGINE_ID_NIC1_0,577GAUDI2_ENGINE_ID_NIC1_1,578GAUDI2_ENGINE_ID_NIC2_0,579GAUDI2_ENGINE_ID_NIC2_1,580GAUDI2_ENGINE_ID_NIC3_0,581GAUDI2_ENGINE_ID_NIC3_1,582GAUDI2_ENGINE_ID_NIC4_0,583GAUDI2_ENGINE_ID_NIC4_1,584GAUDI2_ENGINE_ID_NIC5_0,585GAUDI2_ENGINE_ID_NIC5_1,586GAUDI2_ENGINE_ID_NIC6_0,587GAUDI2_ENGINE_ID_NIC6_1,588GAUDI2_ENGINE_ID_NIC7_0,589GAUDI2_ENGINE_ID_NIC7_1,590GAUDI2_ENGINE_ID_NIC8_0,591GAUDI2_ENGINE_ID_NIC8_1,592GAUDI2_ENGINE_ID_NIC9_0,593GAUDI2_ENGINE_ID_NIC9_1,594GAUDI2_ENGINE_ID_NIC10_0,595GAUDI2_ENGINE_ID_NIC10_1,596GAUDI2_ENGINE_ID_NIC11_0,597GAUDI2_ENGINE_ID_NIC11_1,598GAUDI2_ENGINE_ID_PCIE,599GAUDI2_ENGINE_ID_PSOC,600GAUDI2_ENGINE_ID_ARC_FARM,601GAUDI2_ENGINE_ID_KDMA,602GAUDI2_ENGINE_ID_SIZE603};604605/*606* ASIC specific PLL index607*608* Used to retrieve in frequency info of different IPs via HL_INFO_PLL_FREQUENCY under609* DRM_IOCTL_HL_INFO IOCTL.610* The enums need to be used as an index in struct hl_pll_frequency_info.611*/612613enum hl_goya_pll_index {614HL_GOYA_CPU_PLL = 0,615HL_GOYA_IC_PLL,616HL_GOYA_MC_PLL,617HL_GOYA_MME_PLL,618HL_GOYA_PCI_PLL,619HL_GOYA_EMMC_PLL,620HL_GOYA_TPC_PLL,621HL_GOYA_PLL_MAX622};623624enum hl_gaudi_pll_index {625HL_GAUDI_CPU_PLL = 0,626HL_GAUDI_PCI_PLL,627HL_GAUDI_SRAM_PLL,628HL_GAUDI_HBM_PLL,629HL_GAUDI_NIC_PLL,630HL_GAUDI_DMA_PLL,631HL_GAUDI_MESH_PLL,632HL_GAUDI_MME_PLL,633HL_GAUDI_TPC_PLL,634HL_GAUDI_IF_PLL,635HL_GAUDI_PLL_MAX636};637638enum hl_gaudi2_pll_index {639HL_GAUDI2_CPU_PLL = 0,640HL_GAUDI2_PCI_PLL,641HL_GAUDI2_SRAM_PLL,642HL_GAUDI2_HBM_PLL,643HL_GAUDI2_NIC_PLL,644HL_GAUDI2_DMA_PLL,645HL_GAUDI2_MESH_PLL,646HL_GAUDI2_MME_PLL,647HL_GAUDI2_TPC_PLL,648HL_GAUDI2_IF_PLL,649HL_GAUDI2_VID_PLL,650HL_GAUDI2_MSS_PLL,651HL_GAUDI2_PLL_MAX652};653654/**655* enum hl_goya_dma_direction - Direction of DMA operation inside a LIN_DMA packet that is656* submitted to the GOYA's DMA QMAN. This attribute is not relevant657* to the H/W but the kernel driver use it to parse the packet's658* addresses and patch/validate them.659* @HL_DMA_HOST_TO_DRAM: DMA operation from Host memory to GOYA's DDR.660* @HL_DMA_HOST_TO_SRAM: DMA operation from Host memory to GOYA's SRAM.661* @HL_DMA_DRAM_TO_SRAM: DMA operation from GOYA's DDR to GOYA's SRAM.662* @HL_DMA_SRAM_TO_DRAM: DMA operation from GOYA's SRAM to GOYA's DDR.663* @HL_DMA_SRAM_TO_HOST: DMA operation from GOYA's SRAM to Host memory.664* @HL_DMA_DRAM_TO_HOST: DMA operation from GOYA's DDR to Host memory.665* @HL_DMA_DRAM_TO_DRAM: DMA operation from GOYA's DDR to GOYA's DDR.666* @HL_DMA_SRAM_TO_SRAM: DMA operation from GOYA's SRAM to GOYA's SRAM.667* @HL_DMA_ENUM_MAX: number of values in enum668*/669enum hl_goya_dma_direction {670HL_DMA_HOST_TO_DRAM,671HL_DMA_HOST_TO_SRAM,672HL_DMA_DRAM_TO_SRAM,673HL_DMA_SRAM_TO_DRAM,674HL_DMA_SRAM_TO_HOST,675HL_DMA_DRAM_TO_HOST,676HL_DMA_DRAM_TO_DRAM,677HL_DMA_SRAM_TO_SRAM,678HL_DMA_ENUM_MAX679};680681/**682* enum hl_device_status - Device status information.683* @HL_DEVICE_STATUS_OPERATIONAL: Device is operational.684* @HL_DEVICE_STATUS_IN_RESET: Device is currently during reset.685* @HL_DEVICE_STATUS_MALFUNCTION: Device is unusable.686* @HL_DEVICE_STATUS_NEEDS_RESET: Device needs reset because auto reset was disabled.687* @HL_DEVICE_STATUS_IN_DEVICE_CREATION: Device is operational but its creation is still in688* progress.689* @HL_DEVICE_STATUS_IN_RESET_AFTER_DEVICE_RELEASE: Device is currently during reset that was690* triggered because the user released the device691* @HL_DEVICE_STATUS_LAST: Last status.692*/693enum hl_device_status {694HL_DEVICE_STATUS_OPERATIONAL,695HL_DEVICE_STATUS_IN_RESET,696HL_DEVICE_STATUS_MALFUNCTION,697HL_DEVICE_STATUS_NEEDS_RESET,698HL_DEVICE_STATUS_IN_DEVICE_CREATION,699HL_DEVICE_STATUS_IN_RESET_AFTER_DEVICE_RELEASE,700HL_DEVICE_STATUS_LAST = HL_DEVICE_STATUS_IN_RESET_AFTER_DEVICE_RELEASE701};702703enum hl_server_type {704HL_SERVER_TYPE_UNKNOWN = 0,705HL_SERVER_GAUDI_HLS1 = 1,706HL_SERVER_GAUDI_HLS1H = 2,707HL_SERVER_GAUDI_TYPE1 = 3,708HL_SERVER_GAUDI_TYPE2 = 4,709HL_SERVER_GAUDI2_HLS2 = 5,710HL_SERVER_GAUDI2_TYPE1 = 7711};712713/*714* Notifier event values - for the notification mechanism and the HL_INFO_GET_EVENTS command715*716* HL_NOTIFIER_EVENT_TPC_ASSERT - Indicates TPC assert event717* HL_NOTIFIER_EVENT_UNDEFINED_OPCODE - Indicates undefined operation code718* HL_NOTIFIER_EVENT_DEVICE_RESET - Indicates device requires a reset719* HL_NOTIFIER_EVENT_CS_TIMEOUT - Indicates CS timeout error720* HL_NOTIFIER_EVENT_DEVICE_UNAVAILABLE - Indicates device is unavailable721* HL_NOTIFIER_EVENT_USER_ENGINE_ERR - Indicates device engine in error state722* HL_NOTIFIER_EVENT_GENERAL_HW_ERR - Indicates device HW error723* HL_NOTIFIER_EVENT_RAZWI - Indicates razwi happened724* HL_NOTIFIER_EVENT_PAGE_FAULT - Indicates page fault happened725* HL_NOTIFIER_EVENT_CRITICAL_HW_ERR - Indicates a HW error that requires SW abort and726* HW reset727* HL_NOTIFIER_EVENT_CRITICAL_FW_ERR - Indicates a FW error that requires SW abort and728* HW reset729*/730#define HL_NOTIFIER_EVENT_TPC_ASSERT (1ULL << 0)731#define HL_NOTIFIER_EVENT_UNDEFINED_OPCODE (1ULL << 1)732#define HL_NOTIFIER_EVENT_DEVICE_RESET (1ULL << 2)733#define HL_NOTIFIER_EVENT_CS_TIMEOUT (1ULL << 3)734#define HL_NOTIFIER_EVENT_DEVICE_UNAVAILABLE (1ULL << 4)735#define HL_NOTIFIER_EVENT_USER_ENGINE_ERR (1ULL << 5)736#define HL_NOTIFIER_EVENT_GENERAL_HW_ERR (1ULL << 6)737#define HL_NOTIFIER_EVENT_RAZWI (1ULL << 7)738#define HL_NOTIFIER_EVENT_PAGE_FAULT (1ULL << 8)739#define HL_NOTIFIER_EVENT_CRITICL_HW_ERR (1ULL << 9)740#define HL_NOTIFIER_EVENT_CRITICL_FW_ERR (1ULL << 10)741742/* Opcode for management ioctl743*744* HW_IP_INFO - Receive information about different IP blocks in the745* device.746* HL_INFO_HW_EVENTS - Receive an array describing how many times each event747* occurred since the last hard reset.748* HL_INFO_DRAM_USAGE - Retrieve the dram usage inside the device and of the749* specific context. This is relevant only for devices750* where the dram is managed by the kernel driver751* HL_INFO_HW_IDLE - Retrieve information about the idle status of each752* internal engine.753* HL_INFO_DEVICE_STATUS - Retrieve the device's status. This opcode doesn't754* require an open context.755* HL_INFO_DEVICE_UTILIZATION - Retrieve the total utilization of the device756* over the last period specified by the user.757* The period can be between 100ms to 1s, in758* resolution of 100ms. The return value is a759* percentage of the utilization rate.760* HL_INFO_HW_EVENTS_AGGREGATE - Receive an array describing how many times each761* event occurred since the driver was loaded.762* HL_INFO_CLK_RATE - Retrieve the current and maximum clock rate763* of the device in MHz. The maximum clock rate is764* configurable via sysfs parameter765* HL_INFO_RESET_COUNT - Retrieve the counts of the soft and hard reset766* operations performed on the device since the last767* time the driver was loaded.768* HL_INFO_TIME_SYNC - Retrieve the device's time alongside the host's time769* for synchronization.770* HL_INFO_CS_COUNTERS - Retrieve command submission counters771* HL_INFO_PCI_COUNTERS - Retrieve PCI counters772* HL_INFO_CLK_THROTTLE_REASON - Retrieve clock throttling reason773* HL_INFO_SYNC_MANAGER - Retrieve sync manager info per dcore774* HL_INFO_TOTAL_ENERGY - Retrieve total energy consumption775* HL_INFO_PLL_FREQUENCY - Retrieve PLL frequency776* HL_INFO_POWER - Retrieve power information777* HL_INFO_OPEN_STATS - Retrieve info regarding recent device open calls778* HL_INFO_DRAM_REPLACED_ROWS - Retrieve DRAM replaced rows info779* HL_INFO_DRAM_PENDING_ROWS - Retrieve DRAM pending rows num780* HL_INFO_LAST_ERR_OPEN_DEV_TIME - Retrieve timestamp of the last time the device was opened781* and CS timeout or razwi error occurred.782* HL_INFO_CS_TIMEOUT_EVENT - Retrieve CS timeout timestamp and its related CS sequence number.783* HL_INFO_RAZWI_EVENT - Retrieve parameters of razwi:784* Timestamp of razwi.785* The address which accessing it caused the razwi.786* Razwi initiator.787* Razwi cause, was it a page fault or MMU access error.788* May return 0 even though no new data is available, in that case789* timestamp will be 0.790* HL_INFO_DEV_MEM_ALLOC_PAGE_SIZES - Retrieve valid page sizes for device memory allocation791* HL_INFO_SECURED_ATTESTATION - Retrieve attestation report of the boot.792* HL_INFO_REGISTER_EVENTFD - Register eventfd for event notifications.793* HL_INFO_UNREGISTER_EVENTFD - Unregister eventfd794* HL_INFO_GET_EVENTS - Retrieve the last occurred events795* HL_INFO_UNDEFINED_OPCODE_EVENT - Retrieve last undefined opcode error information.796* May return 0 even though no new data is available, in that case797* timestamp will be 0.798* HL_INFO_ENGINE_STATUS - Retrieve the status of all the h/w engines in the asic.799* HL_INFO_PAGE_FAULT_EVENT - Retrieve parameters of captured page fault.800* May return 0 even though no new data is available, in that case801* timestamp will be 0.802* HL_INFO_USER_MAPPINGS - Retrieve user mappings, captured after page fault event.803* HL_INFO_FW_GENERIC_REQ - Send generic request to FW.804* HL_INFO_HW_ERR_EVENT - Retrieve information on the reported HW error.805* May return 0 even though no new data is available, in that case806* timestamp will be 0.807* HL_INFO_FW_ERR_EVENT - Retrieve information on the reported FW error.808* May return 0 even though no new data is available, in that case809* timestamp will be 0.810* HL_INFO_USER_ENGINE_ERR_EVENT - Retrieve the last engine id that reported an error.811*/812#define HL_INFO_HW_IP_INFO 0813#define HL_INFO_HW_EVENTS 1814#define HL_INFO_DRAM_USAGE 2815#define HL_INFO_HW_IDLE 3816#define HL_INFO_DEVICE_STATUS 4817#define HL_INFO_DEVICE_UTILIZATION 6818#define HL_INFO_HW_EVENTS_AGGREGATE 7819#define HL_INFO_CLK_RATE 8820#define HL_INFO_RESET_COUNT 9821#define HL_INFO_TIME_SYNC 10822#define HL_INFO_CS_COUNTERS 11823#define HL_INFO_PCI_COUNTERS 12824#define HL_INFO_CLK_THROTTLE_REASON 13825#define HL_INFO_SYNC_MANAGER 14826#define HL_INFO_TOTAL_ENERGY 15827#define HL_INFO_PLL_FREQUENCY 16828#define HL_INFO_POWER 17829#define HL_INFO_OPEN_STATS 18830#define HL_INFO_DRAM_REPLACED_ROWS 21831#define HL_INFO_DRAM_PENDING_ROWS 22832#define HL_INFO_LAST_ERR_OPEN_DEV_TIME 23833#define HL_INFO_CS_TIMEOUT_EVENT 24834#define HL_INFO_RAZWI_EVENT 25835#define HL_INFO_DEV_MEM_ALLOC_PAGE_SIZES 26836#define HL_INFO_SECURED_ATTESTATION 27837#define HL_INFO_REGISTER_EVENTFD 28838#define HL_INFO_UNREGISTER_EVENTFD 29839#define HL_INFO_GET_EVENTS 30840#define HL_INFO_UNDEFINED_OPCODE_EVENT 31841#define HL_INFO_ENGINE_STATUS 32842#define HL_INFO_PAGE_FAULT_EVENT 33843#define HL_INFO_USER_MAPPINGS 34844#define HL_INFO_FW_GENERIC_REQ 35845#define HL_INFO_HW_ERR_EVENT 36846#define HL_INFO_FW_ERR_EVENT 37847#define HL_INFO_USER_ENGINE_ERR_EVENT 38848#define HL_INFO_DEV_SIGNED 40849850#define HL_INFO_VERSION_MAX_LEN 128851#define HL_INFO_CARD_NAME_MAX_LEN 16852853/* Maximum buffer size for retrieving engines status */854#define HL_ENGINES_DATA_MAX_SIZE SZ_1M855856/**857* struct hl_info_hw_ip_info - hardware information on various IPs in the ASIC858* @sram_base_address: The first SRAM physical base address that is free to be859* used by the user.860* @dram_base_address: The first DRAM virtual or physical base address that is861* free to be used by the user.862* @dram_size: The DRAM size that is available to the user.863* @sram_size: The SRAM size that is available to the user.864* @num_of_events: The number of events that can be received from the f/w. This865* is needed so the user can what is the size of the h/w events866* array he needs to pass to the kernel when he wants to fetch867* the event counters.868* @device_id: PCI device ID of the ASIC.869* @module_id: Module ID of the ASIC for mezzanine cards in servers870* (From OCP spec).871* @decoder_enabled_mask: Bit-mask that represents which decoders are enabled.872* @first_available_interrupt_id: The first available interrupt ID for the user873* to be used when it works with user interrupts.874* Relevant for Gaudi2 and later.875* @server_type: Server type that the Gaudi ASIC is currently installed in.876* The value is according to enum hl_server_type877* @cpld_version: CPLD version on the board.878* @psoc_pci_pll_nr: PCI PLL NR value. Needed by the profiler in some ASICs.879* @psoc_pci_pll_nf: PCI PLL NF value. Needed by the profiler in some ASICs.880* @psoc_pci_pll_od: PCI PLL OD value. Needed by the profiler in some ASICs.881* @psoc_pci_pll_div_factor: PCI PLL DIV factor value. Needed by the profiler882* in some ASICs.883* @tpc_enabled_mask: Bit-mask that represents which TPCs are enabled. Relevant884* for Goya/Gaudi only.885* @dram_enabled: Whether the DRAM is enabled.886* @security_enabled: Whether security is enabled on device.887* @mme_master_slave_mode: Indicate whether the MME is working in master/slave888* configuration. Relevant for Gaudi2 and later.889* @cpucp_version: The CPUCP f/w version.890* @card_name: The card name as passed by the f/w.891* @tpc_enabled_mask_ext: Bit-mask that represents which TPCs are enabled.892* Relevant for Gaudi2 and later.893* @dram_page_size: The DRAM physical page size.894* @edma_enabled_mask: Bit-mask that represents which EDMAs are enabled.895* Relevant for Gaudi2 and later.896* @number_of_user_interrupts: The number of interrupts that are available to the userspace897* application to use. Relevant for Gaudi2 and later.898* @device_mem_alloc_default_page_size: default page size used in device memory allocation.899* @revision_id: PCI revision ID of the ASIC.900* @tpc_interrupt_id: interrupt id for TPC to use in order to raise events towards the host.901* @rotator_enabled_mask: Bit-mask that represents which rotators are enabled.902* Relevant for Gaudi3 and later.903* @engine_core_interrupt_reg_addr: interrupt register address for engine core to use904* in order to raise events toward FW.905* @reserved_dram_size: DRAM size reserved for driver and firmware.906*/907struct hl_info_hw_ip_info {908__u64 sram_base_address;909__u64 dram_base_address;910__u64 dram_size;911__u32 sram_size;912__u32 num_of_events;913__u32 device_id;914__u32 module_id;915__u32 decoder_enabled_mask;916__u16 first_available_interrupt_id;917__u16 server_type;918__u32 cpld_version;919__u32 psoc_pci_pll_nr;920__u32 psoc_pci_pll_nf;921__u32 psoc_pci_pll_od;922__u32 psoc_pci_pll_div_factor;923__u8 tpc_enabled_mask;924__u8 dram_enabled;925__u8 security_enabled;926__u8 mme_master_slave_mode;927__u8 cpucp_version[HL_INFO_VERSION_MAX_LEN];928__u8 card_name[HL_INFO_CARD_NAME_MAX_LEN];929__u64 tpc_enabled_mask_ext;930__u64 dram_page_size;931__u32 edma_enabled_mask;932__u16 number_of_user_interrupts;933__u8 reserved1;934__u8 reserved2;935__u64 reserved3;936__u64 device_mem_alloc_default_page_size;937__u64 reserved4;938__u64 reserved5;939__u32 reserved6;940__u8 reserved7;941__u8 revision_id;942__u16 tpc_interrupt_id;943__u32 rotator_enabled_mask;944__u32 reserved9;945__u64 engine_core_interrupt_reg_addr;946__u64 reserved_dram_size;947};948949struct hl_info_dram_usage {950__u64 dram_free_mem;951__u64 ctx_dram_mem;952};953954#define HL_BUSY_ENGINES_MASK_EXT_SIZE 4955956struct hl_info_hw_idle {957__u32 is_idle;958/*959* Bitmask of busy engines.960* Bits definition is according to `enum <chip>_engine_id'.961*/962__u32 busy_engines_mask;963964/*965* Extended Bitmask of busy engines.966* Bits definition is according to `enum <chip>_engine_id'.967*/968__u64 busy_engines_mask_ext[HL_BUSY_ENGINES_MASK_EXT_SIZE];969};970971struct hl_info_device_status {972__u32 status;973__u32 pad;974};975976struct hl_info_device_utilization {977__u32 utilization;978__u32 pad;979};980981struct hl_info_clk_rate {982__u32 cur_clk_rate_mhz;983__u32 max_clk_rate_mhz;984};985986struct hl_info_reset_count {987__u32 hard_reset_cnt;988__u32 soft_reset_cnt;989};990991struct hl_info_time_sync {992__u64 device_time;993__u64 host_time;994__u64 tsc_time;995};996997/**998* struct hl_info_pci_counters - pci counters999* @rx_throughput: PCI rx throughput KBps1000* @tx_throughput: PCI tx throughput KBps1001* @replay_cnt: PCI replay counter1002*/1003struct hl_info_pci_counters {1004__u64 rx_throughput;1005__u64 tx_throughput;1006__u64 replay_cnt;1007};10081009enum hl_clk_throttling_type {1010HL_CLK_THROTTLE_TYPE_POWER,1011HL_CLK_THROTTLE_TYPE_THERMAL,1012HL_CLK_THROTTLE_TYPE_MAX1013};10141015/* clk_throttling_reason masks */1016#define HL_CLK_THROTTLE_POWER (1 << HL_CLK_THROTTLE_TYPE_POWER)1017#define HL_CLK_THROTTLE_THERMAL (1 << HL_CLK_THROTTLE_TYPE_THERMAL)10181019/**1020* struct hl_info_clk_throttle - clock throttling reason1021* @clk_throttling_reason: each bit represents a clk throttling reason1022* @clk_throttling_timestamp_us: represents CPU timestamp in microseconds of the start-event1023* @clk_throttling_duration_ns: the clock throttle time in nanosec1024*/1025struct hl_info_clk_throttle {1026__u32 clk_throttling_reason;1027__u32 pad;1028__u64 clk_throttling_timestamp_us[HL_CLK_THROTTLE_TYPE_MAX];1029__u64 clk_throttling_duration_ns[HL_CLK_THROTTLE_TYPE_MAX];1030};10311032/**1033* struct hl_info_energy - device energy information1034* @total_energy_consumption: total device energy consumption1035*/1036struct hl_info_energy {1037__u64 total_energy_consumption;1038};10391040#define HL_PLL_NUM_OUTPUTS 410411042struct hl_pll_frequency_info {1043__u16 output[HL_PLL_NUM_OUTPUTS];1044};10451046/**1047* struct hl_open_stats_info - device open statistics information1048* @open_counter: ever growing counter, increased on each successful dev open1049* @last_open_period_ms: duration (ms) device was open last time1050* @is_compute_ctx_active: Whether there is an active compute context executing1051* @compute_ctx_in_release: true if the current compute context is being released1052*/1053struct hl_open_stats_info {1054__u64 open_counter;1055__u64 last_open_period_ms;1056__u8 is_compute_ctx_active;1057__u8 compute_ctx_in_release;1058__u8 pad[6];1059};10601061/**1062* struct hl_power_info - power information1063* @power: power consumption1064*/1065struct hl_power_info {1066__u64 power;1067};10681069/**1070* struct hl_info_sync_manager - sync manager information1071* @first_available_sync_object: first available sob1072* @first_available_monitor: first available monitor1073* @first_available_cq: first available cq1074*/1075struct hl_info_sync_manager {1076__u32 first_available_sync_object;1077__u32 first_available_monitor;1078__u32 first_available_cq;1079__u32 reserved;1080};10811082/**1083* struct hl_info_cs_counters - command submission counters1084* @total_out_of_mem_drop_cnt: total dropped due to memory allocation issue1085* @ctx_out_of_mem_drop_cnt: context dropped due to memory allocation issue1086* @total_parsing_drop_cnt: total dropped due to error in packet parsing1087* @ctx_parsing_drop_cnt: context dropped due to error in packet parsing1088* @total_queue_full_drop_cnt: total dropped due to queue full1089* @ctx_queue_full_drop_cnt: context dropped due to queue full1090* @total_device_in_reset_drop_cnt: total dropped due to device in reset1091* @ctx_device_in_reset_drop_cnt: context dropped due to device in reset1092* @total_max_cs_in_flight_drop_cnt: total dropped due to maximum CS in-flight1093* @ctx_max_cs_in_flight_drop_cnt: context dropped due to maximum CS in-flight1094* @total_validation_drop_cnt: total dropped due to validation error1095* @ctx_validation_drop_cnt: context dropped due to validation error1096*/1097struct hl_info_cs_counters {1098__u64 total_out_of_mem_drop_cnt;1099__u64 ctx_out_of_mem_drop_cnt;1100__u64 total_parsing_drop_cnt;1101__u64 ctx_parsing_drop_cnt;1102__u64 total_queue_full_drop_cnt;1103__u64 ctx_queue_full_drop_cnt;1104__u64 total_device_in_reset_drop_cnt;1105__u64 ctx_device_in_reset_drop_cnt;1106__u64 total_max_cs_in_flight_drop_cnt;1107__u64 ctx_max_cs_in_flight_drop_cnt;1108__u64 total_validation_drop_cnt;1109__u64 ctx_validation_drop_cnt;1110};11111112/**1113* struct hl_info_last_err_open_dev_time - last error boot information.1114* @timestamp: timestamp of last time the device was opened and error occurred.1115*/1116struct hl_info_last_err_open_dev_time {1117__s64 timestamp;1118};11191120/**1121* struct hl_info_cs_timeout_event - last CS timeout information.1122* @timestamp: timestamp when last CS timeout event occurred.1123* @seq: sequence number of last CS timeout event.1124*/1125struct hl_info_cs_timeout_event {1126__s64 timestamp;1127__u64 seq;1128};11291130#define HL_RAZWI_NA_ENG_ID U16_MAX1131#define HL_RAZWI_MAX_NUM_OF_ENGINES_PER_RTR 1281132#define HL_RAZWI_READ BIT(0)1133#define HL_RAZWI_WRITE BIT(1)1134#define HL_RAZWI_LBW BIT(2)1135#define HL_RAZWI_HBW BIT(3)1136#define HL_RAZWI_RR BIT(4)1137#define HL_RAZWI_ADDR_DEC BIT(5)11381139/**1140* struct hl_info_razwi_event - razwi information.1141* @timestamp: timestamp of razwi.1142* @addr: address which accessing it caused razwi.1143* @engine_id: engine id of the razwi initiator, if it was initiated by engine that does not1144* have engine id it will be set to HL_RAZWI_NA_ENG_ID. If there are several possible1145* engines which caused the razwi, it will hold all of them.1146* @num_of_possible_engines: contains number of possible engine ids. In some asics, razwi indication1147* might be common for several engines and there is no way to get the1148* exact engine. In this way, engine_id array will be filled with all1149* possible engines caused this razwi. Also, there might be possibility1150* in gaudi, where we don't indication on specific engine, in that case1151* the value of this parameter will be zero.1152* @flags: bitmask for additional data: HL_RAZWI_READ - razwi caused by read operation1153* HL_RAZWI_WRITE - razwi caused by write operation1154* HL_RAZWI_LBW - razwi caused by lbw fabric transaction1155* HL_RAZWI_HBW - razwi caused by hbw fabric transaction1156* HL_RAZWI_RR - razwi caused by range register1157* HL_RAZWI_ADDR_DEC - razwi caused by address decode error1158* Note: this data is not supported by all asics, in that case the relevant bits will not1159* be set.1160*/1161struct hl_info_razwi_event {1162__s64 timestamp;1163__u64 addr;1164__u16 engine_id[HL_RAZWI_MAX_NUM_OF_ENGINES_PER_RTR];1165__u16 num_of_possible_engines;1166__u8 flags;1167__u8 pad[5];1168};11691170#define MAX_QMAN_STREAMS_INFO 41171#define OPCODE_INFO_MAX_ADDR_SIZE 81172/**1173* struct hl_info_undefined_opcode_event - info about last undefined opcode error1174* @timestamp: timestamp of the undefined opcode error1175* @cb_addr_streams: CB addresses (per stream) that are currently exists in the PQ1176* entries. In case all streams array entries are1177* filled with values, it means the execution was in Lower-CP.1178* @cq_addr: the address of the current handled command buffer1179* @cq_size: the size of the current handled command buffer1180* @cb_addr_streams_len: num of streams - actual len of cb_addr_streams array.1181* should be equal to 1 in case of undefined opcode1182* in Upper-CP (specific stream) and equal to 4 incase1183* of undefined opcode in Lower-CP.1184* @engine_id: engine-id that the error occurred on1185* @stream_id: the stream id the error occurred on. In case the stream equals to1186* MAX_QMAN_STREAMS_INFO it means the error occurred on a Lower-CP.1187*/1188struct hl_info_undefined_opcode_event {1189__s64 timestamp;1190__u64 cb_addr_streams[MAX_QMAN_STREAMS_INFO][OPCODE_INFO_MAX_ADDR_SIZE];1191__u64 cq_addr;1192__u32 cq_size;1193__u32 cb_addr_streams_len;1194__u32 engine_id;1195__u32 stream_id;1196};11971198/**1199* struct hl_info_hw_err_event - info about HW error1200* @timestamp: timestamp of error occurrence1201* @event_id: The async event ID (specific to each device type).1202* @pad: size padding for u64 granularity.1203*/1204struct hl_info_hw_err_event {1205__s64 timestamp;1206__u16 event_id;1207__u16 pad[3];1208};12091210/* FW error definition for event_type in struct hl_info_fw_err_event */1211enum hl_info_fw_err_type {1212HL_INFO_FW_HEARTBEAT_ERR,1213HL_INFO_FW_REPORTED_ERR,1214};12151216/**1217* struct hl_info_fw_err_event - info about FW error1218* @timestamp: time-stamp of error occurrence1219* @err_type: The type of event as defined in hl_info_fw_err_type.1220* @event_id: The async event ID (specific to each device type, applicable only when event type is1221* HL_INFO_FW_REPORTED_ERR).1222* @pad: size padding for u64 granularity.1223*/1224struct hl_info_fw_err_event {1225__s64 timestamp;1226__u16 err_type;1227__u16 event_id;1228__u32 pad;1229};12301231/**1232* struct hl_info_engine_err_event - engine error info1233* @timestamp: time-stamp of error occurrence1234* @engine_id: engine id who reported the error.1235* @error_count: Amount of errors reported.1236* @pad: size padding for u64 granularity.1237*/1238struct hl_info_engine_err_event {1239__s64 timestamp;1240__u16 engine_id;1241__u16 error_count;1242__u32 pad;1243};12441245/**1246* struct hl_info_dev_memalloc_page_sizes - valid page sizes in device mem alloc information.1247* @page_order_bitmask: bitmap in which a set bit represents the order of the supported page size1248* (e.g. 0x2100000 means that 1MB and 32MB pages are supported).1249*/1250struct hl_info_dev_memalloc_page_sizes {1251__u64 page_order_bitmask;1252};12531254#define SEC_PCR_DATA_BUF_SZ 2561255#define SEC_PCR_QUOTE_BUF_SZ 510 /* (512 - 2) 2 bytes used for size */1256#define SEC_SIGNATURE_BUF_SZ 255 /* (256 - 1) 1 byte used for size */1257#define SEC_PUB_DATA_BUF_SZ 510 /* (512 - 2) 2 bytes used for size */1258#define SEC_CERTIFICATE_BUF_SZ 2046 /* (2048 - 2) 2 bytes used for size */1259#define SEC_DEV_INFO_BUF_SZ 512012601261/*1262* struct hl_info_sec_attest - attestation report of the boot1263* @nonce: number only used once. random number provided by host. this also passed to the quote1264* command as a qualifying data.1265* @pcr_quote_len: length of the attestation quote data (bytes)1266* @pub_data_len: length of the public data (bytes)1267* @certificate_len: length of the certificate (bytes)1268* @pcr_num_reg: number of PCR registers in the pcr_data array1269* @pcr_reg_len: length of each PCR register in the pcr_data array (bytes)1270* @quote_sig_len: length of the attestation report signature (bytes)1271* @pcr_data: raw values of the PCR registers1272* @pcr_quote: attestation report data structure1273* @quote_sig: signature structure of the attestation report1274* @public_data: public key for the signed attestation1275* (outPublic + name + qualifiedName)1276* @certificate: certificate for the attestation signing key1277*/1278struct hl_info_sec_attest {1279__u32 nonce;1280__u16 pcr_quote_len;1281__u16 pub_data_len;1282__u16 certificate_len;1283__u8 pcr_num_reg;1284__u8 pcr_reg_len;1285__u8 quote_sig_len;1286__u8 pcr_data[SEC_PCR_DATA_BUF_SZ];1287__u8 pcr_quote[SEC_PCR_QUOTE_BUF_SZ];1288__u8 quote_sig[SEC_SIGNATURE_BUF_SZ];1289__u8 public_data[SEC_PUB_DATA_BUF_SZ];1290__u8 certificate[SEC_CERTIFICATE_BUF_SZ];1291__u8 pad0[2];1292};12931294/*1295* struct hl_info_signed - device information signed by a secured device.1296* @nonce: number only used once. random number provided by host. this also passed to the quote1297* command as a qualifying data.1298* @pub_data_len: length of the public data (bytes)1299* @certificate_len: length of the certificate (bytes)1300* @info_sig_len: length of the attestation signature (bytes)1301* @public_data: public key info signed info data (outPublic + name + qualifiedName)1302* @certificate: certificate for the signing key1303* @info_sig: signature of the info + nonce data.1304* @dev_info_len: length of device info (bytes)1305* @dev_info: device info as byte array.1306*/1307struct hl_info_signed {1308__u32 nonce;1309__u16 pub_data_len;1310__u16 certificate_len;1311__u8 info_sig_len;1312__u8 public_data[SEC_PUB_DATA_BUF_SZ];1313__u8 certificate[SEC_CERTIFICATE_BUF_SZ];1314__u8 info_sig[SEC_SIGNATURE_BUF_SZ];1315__u16 dev_info_len;1316__u8 dev_info[SEC_DEV_INFO_BUF_SZ];1317__u8 pad[2];1318};13191320/**1321* struct hl_page_fault_info - page fault information.1322* @timestamp: timestamp of page fault.1323* @addr: address which accessing it caused page fault.1324* @engine_id: engine id which caused the page fault, supported only in gaudi3.1325*/1326struct hl_page_fault_info {1327__s64 timestamp;1328__u64 addr;1329__u16 engine_id;1330__u8 pad[6];1331};13321333/**1334* struct hl_user_mapping - user mapping information.1335* @dev_va: device virtual address.1336* @size: virtual address mapping size.1337*/1338struct hl_user_mapping {1339__u64 dev_va;1340__u64 size;1341};13421343enum gaudi_dcores {1344HL_GAUDI_WS_DCORE,1345HL_GAUDI_WN_DCORE,1346HL_GAUDI_EN_DCORE,1347HL_GAUDI_ES_DCORE1348};13491350/**1351* struct hl_info_args - Main structure to retrieve device related information.1352* @return_pointer: User space address of the relevant structure related to HL_INFO_* operation1353* mentioned in @op.1354* @return_size: Size of the structure used in @return_pointer, just like "size" in "snprintf", it1355* limits how many bytes the kernel can write. For hw_events array, the size should be1356* hl_info_hw_ip_info.num_of_events * sizeof(__u32).1357* @op: Defines which type of information to be retrieved. Refer HL_INFO_* for details.1358* @dcore_id: DCORE id for which the information is relevant (for Gaudi refer to enum gaudi_dcores).1359* @ctx_id: Context ID of the user. Currently not in use.1360* @period_ms: Period value, in milliseconds, for utilization rate in range 100ms - 1000ms in 100 ms1361* resolution. Currently not in use.1362* @pll_index: Index as defined in hl_<asic type>_pll_index enumeration.1363* @eventfd: event file descriptor for event notifications.1364* @user_buffer_actual_size: Actual data size which was copied to user allocated buffer by the1365* driver. It is possible for the user to allocate buffer larger than1366* needed, hence updating this variable so user will know the exact amount1367* of bytes copied by the kernel to the buffer.1368* @sec_attest_nonce: Nonce number used for attestation report.1369* @array_size: Number of array members copied to user buffer.1370* Relevant for HL_INFO_USER_MAPPINGS info ioctl.1371* @fw_sub_opcode: generic requests sub opcodes.1372* @pad: Padding to 64 bit.1373*/1374struct hl_info_args {1375__u64 return_pointer;1376__u32 return_size;1377__u32 op;13781379union {1380__u32 dcore_id;1381__u32 ctx_id;1382__u32 period_ms;1383__u32 pll_index;1384__u32 eventfd;1385__u32 user_buffer_actual_size;1386__u32 sec_attest_nonce;1387__u32 array_size;1388__u32 fw_sub_opcode;1389};13901391__u32 pad;1392};13931394/* Opcode to create a new command buffer */1395#define HL_CB_OP_CREATE 01396/* Opcode to destroy previously created command buffer */1397#define HL_CB_OP_DESTROY 11398/* Opcode to retrieve information about a command buffer */1399#define HL_CB_OP_INFO 214001401/* 2MB minus 32 bytes for 2xMSG_PROT */1402#define HL_MAX_CB_SIZE (0x200000 - 32)14031404/* Indicates whether the command buffer should be mapped to the device's MMU */1405#define HL_CB_FLAGS_MAP 0x114061407/* Used with HL_CB_OP_INFO opcode to get the device va address for kernel mapped CB */1408#define HL_CB_FLAGS_GET_DEVICE_VA 0x214091410struct hl_cb_in {1411/* Handle of CB or 0 if we want to create one */1412__u64 cb_handle;1413/* HL_CB_OP_* */1414__u32 op;14151416/* Size of CB. Maximum size is HL_MAX_CB_SIZE. The minimum size that1417* will be allocated, regardless of this parameter's value, is PAGE_SIZE1418*/1419__u32 cb_size;14201421/* Context ID - Currently not in use */1422__u32 ctx_id;1423/* HL_CB_FLAGS_* */1424__u32 flags;1425};14261427struct hl_cb_out {1428union {1429/* Handle of CB */1430__u64 cb_handle;14311432union {1433/* Information about CB */1434struct {1435/* Usage count of CB */1436__u32 usage_cnt;1437__u32 pad;1438};14391440/* CB mapped address to device MMU */1441__u64 device_va;1442};1443};1444};14451446union hl_cb_args {1447struct hl_cb_in in;1448struct hl_cb_out out;1449};14501451/* HL_CS_CHUNK_FLAGS_ values1452*1453* HL_CS_CHUNK_FLAGS_USER_ALLOC_CB:1454* Indicates if the CB was allocated and mapped by userspace1455* (relevant to Gaudi2 and later). User allocated CB is a command buffer,1456* allocated by the user, via malloc (or similar). After allocating the1457* CB, the user invokes - “memory ioctl” to map the user memory into a1458* device virtual address. The user provides this address via the1459* cb_handle field. The interface provides the ability to create a1460* large CBs, Which aren’t limited to “HL_MAX_CB_SIZE”. Therefore, it1461* increases the PCI-DMA queues throughput. This CB allocation method1462* also reduces the use of Linux DMA-able memory pool. Which are limited1463* and used by other Linux sub-systems.1464*/1465#define HL_CS_CHUNK_FLAGS_USER_ALLOC_CB 0x114661467/*1468* This structure size must always be fixed to 64-bytes for backward1469* compatibility1470*/1471struct hl_cs_chunk {1472union {1473/* Goya/Gaudi:1474* For external queue, this represents a Handle of CB on the1475* Host.1476* For internal queue in Goya, this represents an SRAM or1477* a DRAM address of the internal CB. In Gaudi, this might also1478* represent a mapped host address of the CB.1479*1480* Gaudi2 onwards:1481* For H/W queue, this represents either a Handle of CB on the1482* Host, or an SRAM, a DRAM, or a mapped host address of the CB.1483*1484* A mapped host address is in the device address space, after1485* a host address was mapped by the device MMU.1486*/1487__u64 cb_handle;14881489/* Relevant only when HL_CS_FLAGS_WAIT or1490* HL_CS_FLAGS_COLLECTIVE_WAIT is set1491* This holds address of array of u64 values that contain1492* signal CS sequence numbers. The wait described by1493* this job will listen on all those signals1494* (wait event per signal)1495*/1496__u64 signal_seq_arr;14971498/*1499* Relevant only when HL_CS_FLAGS_WAIT or1500* HL_CS_FLAGS_COLLECTIVE_WAIT is set1501* along with HL_CS_FLAGS_ENCAP_SIGNALS.1502* This is the CS sequence which has the encapsulated signals.1503*/1504__u64 encaps_signal_seq;1505};15061507/* Index of queue to put the CB on */1508__u32 queue_index;15091510union {1511/*1512* Size of command buffer with valid packets1513* Can be smaller then actual CB size1514*/1515__u32 cb_size;15161517/* Relevant only when HL_CS_FLAGS_WAIT or1518* HL_CS_FLAGS_COLLECTIVE_WAIT is set.1519* Number of entries in signal_seq_arr1520*/1521__u32 num_signal_seq_arr;15221523/* Relevant only when HL_CS_FLAGS_WAIT or1524* HL_CS_FLAGS_COLLECTIVE_WAIT is set along1525* with HL_CS_FLAGS_ENCAP_SIGNALS1526* This set the signals range that the user want to wait for1527* out of the whole reserved signals range.1528* e.g if the signals range is 20, and user don't want1529* to wait for signal 8, so he set this offset to 7, then1530* he call the API again with 9 and so on till 20.1531*/1532__u32 encaps_signal_offset;1533};15341535/* HL_CS_CHUNK_FLAGS_* */1536__u32 cs_chunk_flags;15371538/* Relevant only when HL_CS_FLAGS_COLLECTIVE_WAIT is set.1539* This holds the collective engine ID. The wait described by this job1540* will sync with this engine and with all NICs before completion.1541*/1542__u32 collective_engine_id;15431544/* Align structure to 64 bytes */1545__u32 pad[10];1546};15471548/* SIGNAL/WAIT/COLLECTIVE_WAIT flags are mutually exclusive */1549#define HL_CS_FLAGS_FORCE_RESTORE 0x11550#define HL_CS_FLAGS_SIGNAL 0x21551#define HL_CS_FLAGS_WAIT 0x41552#define HL_CS_FLAGS_COLLECTIVE_WAIT 0x815531554#define HL_CS_FLAGS_TIMESTAMP 0x201555#define HL_CS_FLAGS_STAGED_SUBMISSION 0x401556#define HL_CS_FLAGS_STAGED_SUBMISSION_FIRST 0x801557#define HL_CS_FLAGS_STAGED_SUBMISSION_LAST 0x1001558#define HL_CS_FLAGS_CUSTOM_TIMEOUT 0x2001559#define HL_CS_FLAGS_SKIP_RESET_ON_TIMEOUT 0x40015601561/*1562* The encapsulated signals CS is merged into the existing CS ioctls.1563* In order to use this feature need to follow the below procedure:1564* 1. Reserve signals, set the CS type to HL_CS_FLAGS_RESERVE_SIGNALS_ONLY1565* the output of this API will be the SOB offset from CFG_BASE.1566* this address will be used to patch CB cmds to do the signaling for this1567* SOB by incrementing it's value.1568* for reverting the reservation use HL_CS_FLAGS_UNRESERVE_SIGNALS_ONLY1569* CS type, note that this might fail if out-of-sync happened to the SOB1570* value, in case other signaling request to the same SOB occurred between1571* reserve-unreserve calls.1572* 2. Use the staged CS to do the encapsulated signaling jobs.1573* use HL_CS_FLAGS_STAGED_SUBMISSION and HL_CS_FLAGS_STAGED_SUBMISSION_FIRST1574* along with HL_CS_FLAGS_ENCAP_SIGNALS flag, and set encaps_signal_offset1575* field. This offset allows app to wait on part of the reserved signals.1576* 3. Use WAIT/COLLECTIVE WAIT CS along with HL_CS_FLAGS_ENCAP_SIGNALS flag1577* to wait for the encapsulated signals.1578*/1579#define HL_CS_FLAGS_ENCAP_SIGNALS 0x8001580#define HL_CS_FLAGS_RESERVE_SIGNALS_ONLY 0x10001581#define HL_CS_FLAGS_UNRESERVE_SIGNALS_ONLY 0x200015821583/*1584* The engine cores CS is merged into the existing CS ioctls.1585* Use it to control the engine cores mode.1586*/1587#define HL_CS_FLAGS_ENGINE_CORE_COMMAND 0x400015881589/*1590* The flush HBW PCI writes is merged into the existing CS ioctls.1591* Used to flush all HBW PCI writes.1592* This is a blocking operation and for this reason the user shall not use1593* the return sequence number (which will be invalid anyway)1594*/1595#define HL_CS_FLAGS_FLUSH_PCI_HBW_WRITES 0x800015961597/*1598* The engines CS is merged into the existing CS ioctls.1599* Use it to control engines modes.1600*/1601#define HL_CS_FLAGS_ENGINES_COMMAND 0x1000016021603#define HL_CS_STATUS_SUCCESS 016041605#define HL_MAX_JOBS_PER_CS 51216061607/*1608* enum hl_engine_command - engine command1609*1610* @HL_ENGINE_CORE_HALT: engine core halt1611* @HL_ENGINE_CORE_RUN: engine core run1612* @HL_ENGINE_STALL: user engine/s stall1613* @HL_ENGINE_RESUME: user engine/s resume1614*/1615enum hl_engine_command {1616HL_ENGINE_CORE_HALT = 1,1617HL_ENGINE_CORE_RUN = 2,1618HL_ENGINE_STALL = 3,1619HL_ENGINE_RESUME = 4,1620HL_ENGINE_COMMAND_MAX1621};16221623struct hl_cs_in {16241625union {1626struct {1627/* this holds address of array of hl_cs_chunk for restore phase */1628__u64 chunks_restore;16291630/* holds address of array of hl_cs_chunk for execution phase */1631__u64 chunks_execute;1632};16331634/* Valid only when HL_CS_FLAGS_ENGINE_CORE_COMMAND is set */1635struct {1636/* this holds address of array of uint32 for engine_cores */1637__u64 engine_cores;16381639/* number of engine cores in engine_cores array */1640__u32 num_engine_cores;16411642/* the core command to be sent towards engine cores */1643__u32 core_command;1644};16451646/* Valid only when HL_CS_FLAGS_ENGINES_COMMAND is set */1647struct {1648/* this holds address of array of uint32 for engines */1649__u64 engines;16501651/* number of engines in engines array */1652__u32 num_engines;16531654/* the engine command to be sent towards engines */1655__u32 engine_command;1656};1657};16581659union {1660/*1661* Sequence number of a staged submission CS1662* valid only if HL_CS_FLAGS_STAGED_SUBMISSION is set and1663* HL_CS_FLAGS_STAGED_SUBMISSION_FIRST is unset.1664*/1665__u64 seq;16661667/*1668* Encapsulated signals handle id1669* Valid for two flows:1670* 1. CS with encapsulated signals:1671* when HL_CS_FLAGS_STAGED_SUBMISSION and1672* HL_CS_FLAGS_STAGED_SUBMISSION_FIRST1673* and HL_CS_FLAGS_ENCAP_SIGNALS are set.1674* 2. unreserve signals:1675* valid when HL_CS_FLAGS_UNRESERVE_SIGNALS_ONLY is set.1676*/1677__u32 encaps_sig_handle_id;16781679/* Valid only when HL_CS_FLAGS_RESERVE_SIGNALS_ONLY is set */1680struct {1681/* Encapsulated signals number */1682__u32 encaps_signals_count;16831684/* Encapsulated signals queue index (stream) */1685__u32 encaps_signals_q_idx;1686};1687};16881689/* Number of chunks in restore phase array. Maximum number is1690* HL_MAX_JOBS_PER_CS1691*/1692__u32 num_chunks_restore;16931694/* Number of chunks in execution array. Maximum number is1695* HL_MAX_JOBS_PER_CS1696*/1697__u32 num_chunks_execute;16981699/* timeout in seconds - valid only if HL_CS_FLAGS_CUSTOM_TIMEOUT1700* is set1701*/1702__u32 timeout;17031704/* HL_CS_FLAGS_* */1705__u32 cs_flags;17061707/* Context ID - Currently not in use */1708__u32 ctx_id;1709__u8 pad[4];1710};17111712struct hl_cs_out {1713union {1714/*1715* seq holds the sequence number of the CS to pass to wait1716* ioctl. All values are valid except for 0 and ULLONG_MAX1717*/1718__u64 seq;17191720/* Valid only when HL_CS_FLAGS_RESERVE_SIGNALS_ONLY is set */1721struct {1722/* This is the reserved signal handle id */1723__u32 handle_id;17241725/* This is the signals count */1726__u32 count;1727};1728};17291730/* HL_CS_STATUS */1731__u32 status;17321733/*1734* SOB base address offset1735* Valid only when HL_CS_FLAGS_RESERVE_SIGNALS_ONLY or HL_CS_FLAGS_SIGNAL is set1736*/1737__u32 sob_base_addr_offset;17381739/*1740* Count of completed signals in SOB before current signal submission.1741* Valid only when (HL_CS_FLAGS_ENCAP_SIGNALS & HL_CS_FLAGS_STAGED_SUBMISSION)1742* or HL_CS_FLAGS_SIGNAL is set1743*/1744__u16 sob_count_before_submission;1745__u16 pad[3];1746};17471748union hl_cs_args {1749struct hl_cs_in in;1750struct hl_cs_out out;1751};17521753#define HL_WAIT_CS_FLAGS_INTERRUPT 0x21754#define HL_WAIT_CS_FLAGS_INTERRUPT_MASK 0xFFF000001755#define HL_WAIT_CS_FLAGS_ANY_CQ_INTERRUPT 0xFFF000001756#define HL_WAIT_CS_FLAGS_ANY_DEC_INTERRUPT 0xFFE000001757#define HL_WAIT_CS_FLAGS_MULTI_CS 0x41758#define HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ 0x101759#define HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT 0x2017601761#define HL_WAIT_MULTI_CS_LIST_MAX_LEN 3217621763struct hl_wait_cs_in {1764union {1765struct {1766/*1767* In case of wait_cs holds the CS sequence number.1768* In case of wait for multi CS hold a user pointer to1769* an array of CS sequence numbers1770*/1771__u64 seq;1772/* Absolute timeout to wait for command submission1773* in microseconds1774*/1775__u64 timeout_us;1776};17771778struct {1779union {1780/* User address for completion comparison.1781* upon interrupt, driver will compare the value pointed1782* by this address with the supplied target value.1783* in order not to perform any comparison, set address1784* to all 1s.1785* Relevant only when HL_WAIT_CS_FLAGS_INTERRUPT is set1786*/1787__u64 addr;17881789/* cq_counters_handle to a kernel mapped cb which contains1790* cq counters.1791* Relevant only when HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ is set1792*/1793__u64 cq_counters_handle;1794};17951796/* Target value for completion comparison */1797__u64 target;1798};1799};18001801/* Context ID - Currently not in use */1802__u32 ctx_id;18031804/* HL_WAIT_CS_FLAGS_*1805* If HL_WAIT_CS_FLAGS_INTERRUPT is set, this field should include1806* interrupt id according to HL_WAIT_CS_FLAGS_INTERRUPT_MASK1807*1808* in order to wait for any CQ interrupt, set interrupt value to1809* HL_WAIT_CS_FLAGS_ANY_CQ_INTERRUPT.1810*1811* in order to wait for any decoder interrupt, set interrupt value to1812* HL_WAIT_CS_FLAGS_ANY_DEC_INTERRUPT.1813*/1814__u32 flags;18151816union {1817struct {1818/* Multi CS API info- valid entries in multi-CS array */1819__u8 seq_arr_len;1820__u8 pad[7];1821};18221823/* Absolute timeout to wait for an interrupt in microseconds.1824* Relevant only when HL_WAIT_CS_FLAGS_INTERRUPT is set1825*/1826__u64 interrupt_timeout_us;1827};18281829/*1830* cq counter offset inside the counters cb pointed by cq_counters_handle above.1831* upon interrupt, driver will compare the value pointed1832* by this address (cq_counters_handle + cq_counters_offset)1833* with the supplied target value.1834* relevant only when HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ is set1835*/1836__u64 cq_counters_offset;18371838/*1839* Timestamp_handle timestamps buffer handle.1840* relevant only when HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT is set1841*/1842__u64 timestamp_handle;18431844/*1845* Timestamp_offset is offset inside the timestamp buffer pointed by timestamp_handle above.1846* upon interrupt, if the cq reached the target value then driver will write1847* timestamp to this offset.1848* relevant only when HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT is set1849*/1850__u64 timestamp_offset;1851};18521853#define HL_WAIT_CS_STATUS_COMPLETED 01854#define HL_WAIT_CS_STATUS_BUSY 11855#define HL_WAIT_CS_STATUS_TIMEDOUT 21856#define HL_WAIT_CS_STATUS_ABORTED 318571858#define HL_WAIT_CS_STATUS_FLAG_GONE 0x11859#define HL_WAIT_CS_STATUS_FLAG_TIMESTAMP_VLD 0x218601861struct hl_wait_cs_out {1862/* HL_WAIT_CS_STATUS_* */1863__u32 status;1864/* HL_WAIT_CS_STATUS_FLAG* */1865__u32 flags;1866/*1867* valid only if HL_WAIT_CS_STATUS_FLAG_TIMESTAMP_VLD is set1868* for wait_cs: timestamp of CS completion1869* for wait_multi_cs: timestamp of FIRST CS completion1870*/1871__s64 timestamp_nsec;1872/* multi CS completion bitmap */1873__u32 cs_completion_map;1874__u32 pad;1875};18761877union hl_wait_cs_args {1878struct hl_wait_cs_in in;1879struct hl_wait_cs_out out;1880};18811882/* Opcode to allocate device memory */1883#define HL_MEM_OP_ALLOC 018841885/* Opcode to free previously allocated device memory */1886#define HL_MEM_OP_FREE 118871888/* Opcode to map host and device memory */1889#define HL_MEM_OP_MAP 218901891/* Opcode to unmap previously mapped host and device memory */1892#define HL_MEM_OP_UNMAP 318931894/* Opcode to map a hw block */1895#define HL_MEM_OP_MAP_BLOCK 418961897/* Opcode to create DMA-BUF object for an existing device memory allocation1898* and to export an FD of that DMA-BUF back to the caller1899*/1900#define HL_MEM_OP_EXPORT_DMABUF_FD 519011902/* Opcode to create timestamps pool for user interrupts registration support1903* The memory will be allocated by the kernel driver, A timestamp buffer which the user1904* will get handle to it for mmap, and another internal buffer used by the1905* driver for registration management1906* The memory will be freed when the user closes the file descriptor(ctx close)1907*/1908#define HL_MEM_OP_TS_ALLOC 619091910/* Memory flags */1911#define HL_MEM_CONTIGUOUS 0x11912#define HL_MEM_SHARED 0x21913#define HL_MEM_USERPTR 0x41914#define HL_MEM_FORCE_HINT 0x81915#define HL_MEM_PREFETCH 0x4019161917/**1918* structure hl_mem_in - structure that handle input args for memory IOCTL1919* @union arg: union of structures to be used based on the input operation1920* @op: specify the requested memory operation (one of the HL_MEM_OP_* definitions).1921* @flags: flags for the memory operation (one of the HL_MEM_* definitions).1922* For the HL_MEM_OP_EXPORT_DMABUF_FD opcode, this field holds the DMA-BUF file/FD flags.1923* @ctx_id: context ID - currently not in use.1924* @num_of_elements: number of timestamp elements used only with HL_MEM_OP_TS_ALLOC opcode.1925*/1926struct hl_mem_in {1927union {1928/**1929* structure for device memory allocation (used with the HL_MEM_OP_ALLOC op)1930* @mem_size: memory size to allocate1931* @page_size: page size to use on allocation. when the value is 0 the default page1932* size will be taken.1933*/1934struct {1935__u64 mem_size;1936__u64 page_size;1937} alloc;19381939/**1940* structure for free-ing device memory (used with the HL_MEM_OP_FREE op)1941* @handle: handle returned from HL_MEM_OP_ALLOC1942*/1943struct {1944__u64 handle;1945} free;19461947/**1948* structure for mapping device memory (used with the HL_MEM_OP_MAP op)1949* @hint_addr: requested virtual address of mapped memory.1950* the driver will try to map the requested region to this hint1951* address, as long as the address is valid and not already mapped.1952* the user should check the returned address of the IOCTL to make1953* sure he got the hint address.1954* passing 0 here means that the driver will choose the address itself.1955* @handle: handle returned from HL_MEM_OP_ALLOC.1956*/1957struct {1958__u64 hint_addr;1959__u64 handle;1960} map_device;19611962/**1963* structure for mapping host memory (used with the HL_MEM_OP_MAP op)1964* @host_virt_addr: address of allocated host memory.1965* @hint_addr: requested virtual address of mapped memory.1966* the driver will try to map the requested region to this hint1967* address, as long as the address is valid and not already mapped.1968* the user should check the returned address of the IOCTL to make1969* sure he got the hint address.1970* passing 0 here means that the driver will choose the address itself.1971* @size: size of allocated host memory.1972*/1973struct {1974__u64 host_virt_addr;1975__u64 hint_addr;1976__u64 mem_size;1977} map_host;19781979/**1980* structure for mapping hw block (used with the HL_MEM_OP_MAP_BLOCK op)1981* @block_addr:HW block address to map, a handle and size will be returned1982* to the user and will be used to mmap the relevant block.1983* only addresses from configuration space are allowed.1984*/1985struct {1986__u64 block_addr;1987} map_block;19881989/**1990* structure for unmapping host memory (used with the HL_MEM_OP_UNMAP op)1991* @device_virt_addr: virtual address returned from HL_MEM_OP_MAP1992*/1993struct {1994__u64 device_virt_addr;1995} unmap;19961997/**1998* structure for exporting DMABUF object (used with1999* the HL_MEM_OP_EXPORT_DMABUF_FD op)2000* @addr: for Gaudi1, the driver expects a physical address2001* inside the device's DRAM. this is because in Gaudi12002* we don't have MMU that covers the device's DRAM.2003* for all other ASICs, the driver expects a device2004* virtual address that represents the start address of2005* a mapped DRAM memory area inside the device.2006* the address must be the same as was received from the2007* driver during a previous HL_MEM_OP_MAP operation.2008* @mem_size: size of memory to export.2009* @offset: for Gaudi1, this value must be 0. For all other ASICs,2010* the driver expects an offset inside of the memory area2011* describe by addr. the offset represents the start2012* address of that the exported dma-buf object describes.2013*/2014struct {2015__u64 addr;2016__u64 mem_size;2017__u64 offset;2018} export_dmabuf_fd;2019};20202021__u32 op;2022__u32 flags;2023__u32 ctx_id;2024__u32 num_of_elements;2025};20262027struct hl_mem_out {2028union {2029/*2030* Used for HL_MEM_OP_MAP as the virtual address that was2031* assigned in the device VA space.2032* A value of 0 means the requested operation failed.2033*/2034__u64 device_virt_addr;20352036/*2037* Used in HL_MEM_OP_ALLOC2038* This is the assigned handle for the allocated memory2039*/2040__u64 handle;20412042struct {2043/*2044* Used in HL_MEM_OP_MAP_BLOCK.2045* This is the assigned handle for the mapped block2046*/2047__u64 block_handle;20482049/*2050* Used in HL_MEM_OP_MAP_BLOCK2051* This is the size of the mapped block2052*/2053__u32 block_size;20542055__u32 pad;2056};20572058/* Returned in HL_MEM_OP_EXPORT_DMABUF_FD. Represents the2059* DMA-BUF object that was created to describe a memory2060* allocation on the device's memory space. The FD should be2061* passed to the importer driver2062*/2063__s32 fd;2064};2065};20662067union hl_mem_args {2068struct hl_mem_in in;2069struct hl_mem_out out;2070};20712072#define HL_DEBUG_MAX_AUX_VALUES 1020732074struct hl_debug_params_etr {2075/* Address in memory to allocate buffer */2076__u64 buffer_address;20772078/* Size of buffer to allocate */2079__u64 buffer_size;20802081/* Sink operation mode: SW fifo, HW fifo, Circular buffer */2082__u32 sink_mode;2083__u32 pad;2084};20852086struct hl_debug_params_etf {2087/* Address in memory to allocate buffer */2088__u64 buffer_address;20892090/* Size of buffer to allocate */2091__u64 buffer_size;20922093/* Sink operation mode: SW fifo, HW fifo, Circular buffer */2094__u32 sink_mode;2095__u32 pad;2096};20972098struct hl_debug_params_stm {2099/* Two bit masks for HW event and Stimulus Port */2100__u64 he_mask;2101__u64 sp_mask;21022103/* Trace source ID */2104__u32 id;21052106/* Frequency for the timestamp register */2107__u32 frequency;2108};21092110struct hl_debug_params_bmon {2111/* Two address ranges that the user can request to filter */2112__u64 start_addr0;2113__u64 addr_mask0;21142115__u64 start_addr1;2116__u64 addr_mask1;21172118/* Capture window configuration */2119__u32 bw_win;2120__u32 win_capture;21212122/* Trace source ID */2123__u32 id;21242125/* Control register */2126__u32 control;21272128/* Two more address ranges that the user can request to filter */2129__u64 start_addr2;2130__u64 end_addr2;21312132__u64 start_addr3;2133__u64 end_addr3;2134};21352136struct hl_debug_params_spmu {2137/* Event types selection */2138__u64 event_types[HL_DEBUG_MAX_AUX_VALUES];21392140/* Number of event types selection */2141__u32 event_types_num;21422143/* TRC configuration register values */2144__u32 pmtrc_val;2145__u32 trc_ctrl_host_val;2146__u32 trc_en_host_val;2147};21482149/* Opcode for ETR component */2150#define HL_DEBUG_OP_ETR 02151/* Opcode for ETF component */2152#define HL_DEBUG_OP_ETF 12153/* Opcode for STM component */2154#define HL_DEBUG_OP_STM 22155/* Opcode for FUNNEL component */2156#define HL_DEBUG_OP_FUNNEL 32157/* Opcode for BMON component */2158#define HL_DEBUG_OP_BMON 42159/* Opcode for SPMU component */2160#define HL_DEBUG_OP_SPMU 52161/* Opcode for timestamp (deprecated) */2162#define HL_DEBUG_OP_TIMESTAMP 62163/* Opcode for setting the device into or out of debug mode. The enable2164* variable should be 1 for enabling debug mode and 0 for disabling it2165*/2166#define HL_DEBUG_OP_SET_MODE 721672168struct hl_debug_args {2169/*2170* Pointer to user input structure.2171* This field is relevant to specific opcodes.2172*/2173__u64 input_ptr;2174/* Pointer to user output structure */2175__u64 output_ptr;2176/* Size of user input structure */2177__u32 input_size;2178/* Size of user output structure */2179__u32 output_size;2180/* HL_DEBUG_OP_* */2181__u32 op;2182/*2183* Register index in the component, taken from the debug_regs_index enum2184* in the various ASIC header files2185*/2186__u32 reg_idx;2187/* Enable/disable */2188__u32 enable;2189/* Context ID - Currently not in use */2190__u32 ctx_id;2191};21922193#define HL_IOCTL_INFO 0x002194#define HL_IOCTL_CB 0x012195#define HL_IOCTL_CS 0x022196#define HL_IOCTL_WAIT_CS 0x032197#define HL_IOCTL_MEMORY 0x042198#define HL_IOCTL_DEBUG 0x0521992200/*2201* Various information operations such as:2202* - H/W IP information2203* - Current dram usage2204*2205* The user calls this IOCTL with an opcode that describes the required2206* information. The user should supply a pointer to a user-allocated memory2207* chunk, which will be filled by the driver with the requested information.2208*2209* The user supplies the maximum amount of size to copy into the user's memory,2210* in order to prevent data corruption in case of differences between the2211* definitions of structures in kernel and userspace, e.g. in case of old2212* userspace and new kernel driver2213*/2214#define DRM_IOCTL_HL_INFO DRM_IOWR(DRM_COMMAND_BASE + HL_IOCTL_INFO, struct hl_info_args)22152216/*2217* Command Buffer2218* - Request a Command Buffer2219* - Destroy a Command Buffer2220*2221* The command buffers are memory blocks that reside in DMA-able address2222* space and are physically contiguous so they can be accessed by the device2223* directly. They are allocated using the coherent DMA API.2224*2225* When creating a new CB, the IOCTL returns a handle of it, and the user-space2226* process needs to use that handle to mmap the buffer so it can access them.2227*2228* In some instances, the device must access the command buffer through the2229* device's MMU, and thus its memory should be mapped. In these cases, user can2230* indicate the driver that such a mapping is required.2231* The resulting device virtual address will be used internally by the driver,2232* and won't be returned to user.2233*2234*/2235#define DRM_IOCTL_HL_CB DRM_IOWR(DRM_COMMAND_BASE + HL_IOCTL_CB, union hl_cb_args)22362237/*2238* Command Submission2239*2240* To submit work to the device, the user need to call this IOCTL with a set2241* of JOBS. That set of JOBS constitutes a CS object.2242* Each JOB will be enqueued on a specific queue, according to the user's input.2243* There can be more then one JOB per queue.2244*2245* The CS IOCTL will receive two sets of JOBS. One set is for "restore" phase2246* and a second set is for "execution" phase.2247* The JOBS on the "restore" phase are enqueued only after context-switch2248* (or if its the first CS for this context). The user can also order the2249* driver to run the "restore" phase explicitly2250*2251* Goya/Gaudi:2252* There are two types of queues - external and internal. External queues2253* are DMA queues which transfer data from/to the Host. All other queues are2254* internal. The driver will get completion notifications from the device only2255* on JOBS which are enqueued in the external queues.2256*2257* Gaudi2 onwards:2258* There is a single type of queue for all types of engines, either DMA engines2259* for transfers from/to the host or inside the device, or compute engines.2260* The driver will get completion notifications from the device for all queues.2261*2262* For jobs on external queues, the user needs to create command buffers2263* through the CB ioctl and give the CB's handle to the CS ioctl. For jobs on2264* internal queues, the user needs to prepare a "command buffer" with packets2265* on either the device SRAM/DRAM or the host, and give the device address of2266* that buffer to the CS ioctl.2267* For jobs on H/W queues both options of command buffers are valid.2268*2269* This IOCTL is asynchronous in regard to the actual execution of the CS. This2270* means it returns immediately after ALL the JOBS were enqueued on their2271* relevant queues. Therefore, the user mustn't assume the CS has been completed2272* or has even started to execute.2273*2274* Upon successful enqueue, the IOCTL returns a sequence number which the user2275* can use with the "Wait for CS" IOCTL to check whether the handle's CS2276* non-internal JOBS have been completed. Note that if the CS has internal JOBS2277* which can execute AFTER the external JOBS have finished, the driver might2278* report that the CS has finished executing BEFORE the internal JOBS have2279* actually finished executing.2280*2281* Even though the sequence number increments per CS, the user can NOT2282* automatically assume that if CS with sequence number N finished, then CS2283* with sequence number N-1 also finished. The user can make this assumption if2284* and only if CS N and CS N-1 are exactly the same (same CBs for the same2285* queues).2286*/2287#define DRM_IOCTL_HL_CS DRM_IOWR(DRM_COMMAND_BASE + HL_IOCTL_CS, union hl_cs_args)22882289/*2290* Wait for Command Submission2291*2292* The user can call this IOCTL with a handle it received from the CS IOCTL2293* to wait until the handle's CS has finished executing. The user will wait2294* inside the kernel until the CS has finished or until the user-requested2295* timeout has expired.2296*2297* If the timeout value is 0, the driver won't sleep at all. It will check2298* the status of the CS and return immediately2299*2300* The return value of the IOCTL is a standard Linux error code. The possible2301* values are:2302*2303* EINTR - Kernel waiting has been interrupted, e.g. due to OS signal2304* that the user process received2305* ETIMEDOUT - The CS has caused a timeout on the device2306* EIO - The CS was aborted (usually because the device was reset)2307* ENODEV - The device wants to do hard-reset (so user need to close FD)2308*2309* The driver also returns a custom define in case the IOCTL call returned 0.2310* The define can be one of the following:2311*2312* HL_WAIT_CS_STATUS_COMPLETED - The CS has been completed successfully (0)2313* HL_WAIT_CS_STATUS_BUSY - The CS is still executing (0)2314* HL_WAIT_CS_STATUS_TIMEDOUT - The CS has caused a timeout on the device2315* (ETIMEDOUT)2316* HL_WAIT_CS_STATUS_ABORTED - The CS was aborted, usually because the2317* device was reset (EIO)2318*/2319#define DRM_IOCTL_HL_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + HL_IOCTL_WAIT_CS, union hl_wait_cs_args)23202321/*2322* Memory2323* - Map host memory to device MMU2324* - Unmap host memory from device MMU2325*2326* This IOCTL allows the user to map host memory to the device MMU2327*2328* For host memory, the IOCTL doesn't allocate memory. The user is supposed2329* to allocate the memory in user-space (malloc/new). The driver pins the2330* physical pages (up to the allowed limit by the OS), assigns a virtual2331* address in the device VA space and initializes the device MMU.2332*2333* There is an option for the user to specify the requested virtual address.2334*2335*/2336#define DRM_IOCTL_HL_MEMORY DRM_IOWR(DRM_COMMAND_BASE + HL_IOCTL_MEMORY, union hl_mem_args)23372338/*2339* Debug2340* - Enable/disable the ETR/ETF/FUNNEL/STM/BMON/SPMU debug traces2341*2342* This IOCTL allows the user to get debug traces from the chip.2343*2344* Before the user can send configuration requests of the various2345* debug/profile engines, it needs to set the device into debug mode.2346* This is because the debug/profile infrastructure is shared component in the2347* device and we can't allow multiple users to access it at the same time.2348*2349* Once a user set the device into debug mode, the driver won't allow other2350* users to "work" with the device, i.e. open a FD. If there are multiple users2351* opened on the device, the driver won't allow any user to debug the device.2352*2353* For each configuration request, the user needs to provide the register index2354* and essential data such as buffer address and size.2355*2356* Once the user has finished using the debug/profile engines, he should2357* set the device into non-debug mode, i.e. disable debug mode.2358*2359* The driver can decide to "kick out" the user if he abuses this interface.2360*2361*/2362#define DRM_IOCTL_HL_DEBUG DRM_IOWR(DRM_COMMAND_BASE + HL_IOCTL_DEBUG, struct hl_debug_args)23632364#define HL_COMMAND_START (DRM_COMMAND_BASE + HL_IOCTL_INFO)2365#define HL_COMMAND_END (DRM_COMMAND_BASE + HL_IOCTL_DEBUG + 1)23662367#endif /* HABANALABS_H_ */236823692370