Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
0002  *
0003  * Copyright 2016-2022 HabanaLabs, Ltd.
0004  * All Rights Reserved.
0005  *
0006  */
0007 
0008 #ifndef HABANALABS_H_
0009 #define HABANALABS_H_
0010 
0011 #include <linux/types.h>
0012 #include <linux/ioctl.h>
0013 
0014 /*
0015  * Defines that are asic-specific but constitutes as ABI between kernel driver
0016  * and userspace
0017  */
0018 #define GOYA_KMD_SRAM_RESERVED_SIZE_FROM_START      0x8000  /* 32KB */
0019 #define GAUDI_DRIVER_SRAM_RESERVED_SIZE_FROM_START  0x80    /* 128 bytes */
0020 
0021 /*
0022  * 128 SOBs reserved for collective wait
0023  * 16 SOBs reserved for sync stream
0024  */
0025 #define GAUDI_FIRST_AVAILABLE_W_S_SYNC_OBJECT       144
0026 
0027 /*
0028  * 64 monitors reserved for collective wait
0029  * 8 monitors reserved for sync stream
0030  */
0031 #define GAUDI_FIRST_AVAILABLE_W_S_MONITOR       72
0032 
0033 /* Max number of elements in timestamps registration buffers */
0034 #define TS_MAX_ELEMENTS_NUM             (1 << 20) /* 1MB */
0035 
0036 /*
0037  * Goya queue Numbering
0038  *
0039  * The external queues (PCI DMA channels) MUST be before the internal queues
0040  * and each group (PCI DMA channels and internal) must be contiguous inside
0041  * itself but there can be a gap between the two groups (although not
0042  * recommended)
0043  */
0044 
0045 enum goya_queue_id {
0046     GOYA_QUEUE_ID_DMA_0 = 0,
0047     GOYA_QUEUE_ID_DMA_1 = 1,
0048     GOYA_QUEUE_ID_DMA_2 = 2,
0049     GOYA_QUEUE_ID_DMA_3 = 3,
0050     GOYA_QUEUE_ID_DMA_4 = 4,
0051     GOYA_QUEUE_ID_CPU_PQ = 5,
0052     GOYA_QUEUE_ID_MME = 6,  /* Internal queues start here */
0053     GOYA_QUEUE_ID_TPC0 = 7,
0054     GOYA_QUEUE_ID_TPC1 = 8,
0055     GOYA_QUEUE_ID_TPC2 = 9,
0056     GOYA_QUEUE_ID_TPC3 = 10,
0057     GOYA_QUEUE_ID_TPC4 = 11,
0058     GOYA_QUEUE_ID_TPC5 = 12,
0059     GOYA_QUEUE_ID_TPC6 = 13,
0060     GOYA_QUEUE_ID_TPC7 = 14,
0061     GOYA_QUEUE_ID_SIZE
0062 };
0063 
0064 /*
0065  * Gaudi queue Numbering
0066  * External queues (PCI DMA channels) are DMA_0_*, DMA_1_* and DMA_5_*.
0067  * Except one CPU queue, all the rest are internal queues.
0068  */
0069 
0070 enum gaudi_queue_id {
0071     GAUDI_QUEUE_ID_DMA_0_0 = 0, /* external */
0072     GAUDI_QUEUE_ID_DMA_0_1 = 1, /* external */
0073     GAUDI_QUEUE_ID_DMA_0_2 = 2, /* external */
0074     GAUDI_QUEUE_ID_DMA_0_3 = 3, /* external */
0075     GAUDI_QUEUE_ID_DMA_1_0 = 4, /* external */
0076     GAUDI_QUEUE_ID_DMA_1_1 = 5, /* external */
0077     GAUDI_QUEUE_ID_DMA_1_2 = 6, /* external */
0078     GAUDI_QUEUE_ID_DMA_1_3 = 7, /* external */
0079     GAUDI_QUEUE_ID_CPU_PQ = 8,  /* CPU */
0080     GAUDI_QUEUE_ID_DMA_2_0 = 9, /* internal */
0081     GAUDI_QUEUE_ID_DMA_2_1 = 10,    /* internal */
0082     GAUDI_QUEUE_ID_DMA_2_2 = 11,    /* internal */
0083     GAUDI_QUEUE_ID_DMA_2_3 = 12,    /* internal */
0084     GAUDI_QUEUE_ID_DMA_3_0 = 13,    /* internal */
0085     GAUDI_QUEUE_ID_DMA_3_1 = 14,    /* internal */
0086     GAUDI_QUEUE_ID_DMA_3_2 = 15,    /* internal */
0087     GAUDI_QUEUE_ID_DMA_3_3 = 16,    /* internal */
0088     GAUDI_QUEUE_ID_DMA_4_0 = 17,    /* internal */
0089     GAUDI_QUEUE_ID_DMA_4_1 = 18,    /* internal */
0090     GAUDI_QUEUE_ID_DMA_4_2 = 19,    /* internal */
0091     GAUDI_QUEUE_ID_DMA_4_3 = 20,    /* internal */
0092     GAUDI_QUEUE_ID_DMA_5_0 = 21,    /* internal */
0093     GAUDI_QUEUE_ID_DMA_5_1 = 22,    /* internal */
0094     GAUDI_QUEUE_ID_DMA_5_2 = 23,    /* internal */
0095     GAUDI_QUEUE_ID_DMA_5_3 = 24,    /* internal */
0096     GAUDI_QUEUE_ID_DMA_6_0 = 25,    /* internal */
0097     GAUDI_QUEUE_ID_DMA_6_1 = 26,    /* internal */
0098     GAUDI_QUEUE_ID_DMA_6_2 = 27,    /* internal */
0099     GAUDI_QUEUE_ID_DMA_6_3 = 28,    /* internal */
0100     GAUDI_QUEUE_ID_DMA_7_0 = 29,    /* internal */
0101     GAUDI_QUEUE_ID_DMA_7_1 = 30,    /* internal */
0102     GAUDI_QUEUE_ID_DMA_7_2 = 31,    /* internal */
0103     GAUDI_QUEUE_ID_DMA_7_3 = 32,    /* internal */
0104     GAUDI_QUEUE_ID_MME_0_0 = 33,    /* internal */
0105     GAUDI_QUEUE_ID_MME_0_1 = 34,    /* internal */
0106     GAUDI_QUEUE_ID_MME_0_2 = 35,    /* internal */
0107     GAUDI_QUEUE_ID_MME_0_3 = 36,    /* internal */
0108     GAUDI_QUEUE_ID_MME_1_0 = 37,    /* internal */
0109     GAUDI_QUEUE_ID_MME_1_1 = 38,    /* internal */
0110     GAUDI_QUEUE_ID_MME_1_2 = 39,    /* internal */
0111     GAUDI_QUEUE_ID_MME_1_3 = 40,    /* internal */
0112     GAUDI_QUEUE_ID_TPC_0_0 = 41,    /* internal */
0113     GAUDI_QUEUE_ID_TPC_0_1 = 42,    /* internal */
0114     GAUDI_QUEUE_ID_TPC_0_2 = 43,    /* internal */
0115     GAUDI_QUEUE_ID_TPC_0_3 = 44,    /* internal */
0116     GAUDI_QUEUE_ID_TPC_1_0 = 45,    /* internal */
0117     GAUDI_QUEUE_ID_TPC_1_1 = 46,    /* internal */
0118     GAUDI_QUEUE_ID_TPC_1_2 = 47,    /* internal */
0119     GAUDI_QUEUE_ID_TPC_1_3 = 48,    /* internal */
0120     GAUDI_QUEUE_ID_TPC_2_0 = 49,    /* internal */
0121     GAUDI_QUEUE_ID_TPC_2_1 = 50,    /* internal */
0122     GAUDI_QUEUE_ID_TPC_2_2 = 51,    /* internal */
0123     GAUDI_QUEUE_ID_TPC_2_3 = 52,    /* internal */
0124     GAUDI_QUEUE_ID_TPC_3_0 = 53,    /* internal */
0125     GAUDI_QUEUE_ID_TPC_3_1 = 54,    /* internal */
0126     GAUDI_QUEUE_ID_TPC_3_2 = 55,    /* internal */
0127     GAUDI_QUEUE_ID_TPC_3_3 = 56,    /* internal */
0128     GAUDI_QUEUE_ID_TPC_4_0 = 57,    /* internal */
0129     GAUDI_QUEUE_ID_TPC_4_1 = 58,    /* internal */
0130     GAUDI_QUEUE_ID_TPC_4_2 = 59,    /* internal */
0131     GAUDI_QUEUE_ID_TPC_4_3 = 60,    /* internal */
0132     GAUDI_QUEUE_ID_TPC_5_0 = 61,    /* internal */
0133     GAUDI_QUEUE_ID_TPC_5_1 = 62,    /* internal */
0134     GAUDI_QUEUE_ID_TPC_5_2 = 63,    /* internal */
0135     GAUDI_QUEUE_ID_TPC_5_3 = 64,    /* internal */
0136     GAUDI_QUEUE_ID_TPC_6_0 = 65,    /* internal */
0137     GAUDI_QUEUE_ID_TPC_6_1 = 66,    /* internal */
0138     GAUDI_QUEUE_ID_TPC_6_2 = 67,    /* internal */
0139     GAUDI_QUEUE_ID_TPC_6_3 = 68,    /* internal */
0140     GAUDI_QUEUE_ID_TPC_7_0 = 69,    /* internal */
0141     GAUDI_QUEUE_ID_TPC_7_1 = 70,    /* internal */
0142     GAUDI_QUEUE_ID_TPC_7_2 = 71,    /* internal */
0143     GAUDI_QUEUE_ID_TPC_7_3 = 72,    /* internal */
0144     GAUDI_QUEUE_ID_NIC_0_0 = 73,    /* internal */
0145     GAUDI_QUEUE_ID_NIC_0_1 = 74,    /* internal */
0146     GAUDI_QUEUE_ID_NIC_0_2 = 75,    /* internal */
0147     GAUDI_QUEUE_ID_NIC_0_3 = 76,    /* internal */
0148     GAUDI_QUEUE_ID_NIC_1_0 = 77,    /* internal */
0149     GAUDI_QUEUE_ID_NIC_1_1 = 78,    /* internal */
0150     GAUDI_QUEUE_ID_NIC_1_2 = 79,    /* internal */
0151     GAUDI_QUEUE_ID_NIC_1_3 = 80,    /* internal */
0152     GAUDI_QUEUE_ID_NIC_2_0 = 81,    /* internal */
0153     GAUDI_QUEUE_ID_NIC_2_1 = 82,    /* internal */
0154     GAUDI_QUEUE_ID_NIC_2_2 = 83,    /* internal */
0155     GAUDI_QUEUE_ID_NIC_2_3 = 84,    /* internal */
0156     GAUDI_QUEUE_ID_NIC_3_0 = 85,    /* internal */
0157     GAUDI_QUEUE_ID_NIC_3_1 = 86,    /* internal */
0158     GAUDI_QUEUE_ID_NIC_3_2 = 87,    /* internal */
0159     GAUDI_QUEUE_ID_NIC_3_3 = 88,    /* internal */
0160     GAUDI_QUEUE_ID_NIC_4_0 = 89,    /* internal */
0161     GAUDI_QUEUE_ID_NIC_4_1 = 90,    /* internal */
0162     GAUDI_QUEUE_ID_NIC_4_2 = 91,    /* internal */
0163     GAUDI_QUEUE_ID_NIC_4_3 = 92,    /* internal */
0164     GAUDI_QUEUE_ID_NIC_5_0 = 93,    /* internal */
0165     GAUDI_QUEUE_ID_NIC_5_1 = 94,    /* internal */
0166     GAUDI_QUEUE_ID_NIC_5_2 = 95,    /* internal */
0167     GAUDI_QUEUE_ID_NIC_5_3 = 96,    /* internal */
0168     GAUDI_QUEUE_ID_NIC_6_0 = 97,    /* internal */
0169     GAUDI_QUEUE_ID_NIC_6_1 = 98,    /* internal */
0170     GAUDI_QUEUE_ID_NIC_6_2 = 99,    /* internal */
0171     GAUDI_QUEUE_ID_NIC_6_3 = 100,   /* internal */
0172     GAUDI_QUEUE_ID_NIC_7_0 = 101,   /* internal */
0173     GAUDI_QUEUE_ID_NIC_7_1 = 102,   /* internal */
0174     GAUDI_QUEUE_ID_NIC_7_2 = 103,   /* internal */
0175     GAUDI_QUEUE_ID_NIC_7_3 = 104,   /* internal */
0176     GAUDI_QUEUE_ID_NIC_8_0 = 105,   /* internal */
0177     GAUDI_QUEUE_ID_NIC_8_1 = 106,   /* internal */
0178     GAUDI_QUEUE_ID_NIC_8_2 = 107,   /* internal */
0179     GAUDI_QUEUE_ID_NIC_8_3 = 108,   /* internal */
0180     GAUDI_QUEUE_ID_NIC_9_0 = 109,   /* internal */
0181     GAUDI_QUEUE_ID_NIC_9_1 = 110,   /* internal */
0182     GAUDI_QUEUE_ID_NIC_9_2 = 111,   /* internal */
0183     GAUDI_QUEUE_ID_NIC_9_3 = 112,   /* internal */
0184     GAUDI_QUEUE_ID_SIZE
0185 };
0186 
0187 /*
0188  * In GAUDI2 we have two modes of operation in regard to queues:
0189  * 1. Legacy mode, where each QMAN exposes 4 streams to the user
0190  * 2. F/W mode, where we use F/W to schedule the JOBS to the different queues.
0191  *
0192  * When in legacy mode, the user sends the queue id per JOB according to
0193  * enum gaudi2_queue_id below.
0194  *
0195  * When in F/W mode, the user sends a stream id per Command Submission. The
0196  * stream id is a running number from 0 up to (N-1), where N is the number
0197  * of streams the F/W exposes and is passed to the user in
0198  * struct hl_info_hw_ip_info
0199  */
0200 
0201 enum gaudi2_queue_id {
0202     GAUDI2_QUEUE_ID_PDMA_0_0 = 0,
0203     GAUDI2_QUEUE_ID_PDMA_0_1 = 1,
0204     GAUDI2_QUEUE_ID_PDMA_0_2 = 2,
0205     GAUDI2_QUEUE_ID_PDMA_0_3 = 3,
0206     GAUDI2_QUEUE_ID_PDMA_1_0 = 4,
0207     GAUDI2_QUEUE_ID_PDMA_1_1 = 5,
0208     GAUDI2_QUEUE_ID_PDMA_1_2 = 6,
0209     GAUDI2_QUEUE_ID_PDMA_1_3 = 7,
0210     GAUDI2_QUEUE_ID_DCORE0_EDMA_0_0 = 8,
0211     GAUDI2_QUEUE_ID_DCORE0_EDMA_0_1 = 9,
0212     GAUDI2_QUEUE_ID_DCORE0_EDMA_0_2 = 10,
0213     GAUDI2_QUEUE_ID_DCORE0_EDMA_0_3 = 11,
0214     GAUDI2_QUEUE_ID_DCORE0_EDMA_1_0 = 12,
0215     GAUDI2_QUEUE_ID_DCORE0_EDMA_1_1 = 13,
0216     GAUDI2_QUEUE_ID_DCORE0_EDMA_1_2 = 14,
0217     GAUDI2_QUEUE_ID_DCORE0_EDMA_1_3 = 15,
0218     GAUDI2_QUEUE_ID_DCORE0_MME_0_0 = 16,
0219     GAUDI2_QUEUE_ID_DCORE0_MME_0_1 = 17,
0220     GAUDI2_QUEUE_ID_DCORE0_MME_0_2 = 18,
0221     GAUDI2_QUEUE_ID_DCORE0_MME_0_3 = 19,
0222     GAUDI2_QUEUE_ID_DCORE0_TPC_0_0 = 20,
0223     GAUDI2_QUEUE_ID_DCORE0_TPC_0_1 = 21,
0224     GAUDI2_QUEUE_ID_DCORE0_TPC_0_2 = 22,
0225     GAUDI2_QUEUE_ID_DCORE0_TPC_0_3 = 23,
0226     GAUDI2_QUEUE_ID_DCORE0_TPC_1_0 = 24,
0227     GAUDI2_QUEUE_ID_DCORE0_TPC_1_1 = 25,
0228     GAUDI2_QUEUE_ID_DCORE0_TPC_1_2 = 26,
0229     GAUDI2_QUEUE_ID_DCORE0_TPC_1_3 = 27,
0230     GAUDI2_QUEUE_ID_DCORE0_TPC_2_0 = 28,
0231     GAUDI2_QUEUE_ID_DCORE0_TPC_2_1 = 29,
0232     GAUDI2_QUEUE_ID_DCORE0_TPC_2_2 = 30,
0233     GAUDI2_QUEUE_ID_DCORE0_TPC_2_3 = 31,
0234     GAUDI2_QUEUE_ID_DCORE0_TPC_3_0 = 32,
0235     GAUDI2_QUEUE_ID_DCORE0_TPC_3_1 = 33,
0236     GAUDI2_QUEUE_ID_DCORE0_TPC_3_2 = 34,
0237     GAUDI2_QUEUE_ID_DCORE0_TPC_3_3 = 35,
0238     GAUDI2_QUEUE_ID_DCORE0_TPC_4_0 = 36,
0239     GAUDI2_QUEUE_ID_DCORE0_TPC_4_1 = 37,
0240     GAUDI2_QUEUE_ID_DCORE0_TPC_4_2 = 38,
0241     GAUDI2_QUEUE_ID_DCORE0_TPC_4_3 = 39,
0242     GAUDI2_QUEUE_ID_DCORE0_TPC_5_0 = 40,
0243     GAUDI2_QUEUE_ID_DCORE0_TPC_5_1 = 41,
0244     GAUDI2_QUEUE_ID_DCORE0_TPC_5_2 = 42,
0245     GAUDI2_QUEUE_ID_DCORE0_TPC_5_3 = 43,
0246     GAUDI2_QUEUE_ID_DCORE0_TPC_6_0 = 44,
0247     GAUDI2_QUEUE_ID_DCORE0_TPC_6_1 = 45,
0248     GAUDI2_QUEUE_ID_DCORE0_TPC_6_2 = 46,
0249     GAUDI2_QUEUE_ID_DCORE0_TPC_6_3 = 47,
0250     GAUDI2_QUEUE_ID_DCORE1_EDMA_0_0 = 48,
0251     GAUDI2_QUEUE_ID_DCORE1_EDMA_0_1 = 49,
0252     GAUDI2_QUEUE_ID_DCORE1_EDMA_0_2 = 50,
0253     GAUDI2_QUEUE_ID_DCORE1_EDMA_0_3 = 51,
0254     GAUDI2_QUEUE_ID_DCORE1_EDMA_1_0 = 52,
0255     GAUDI2_QUEUE_ID_DCORE1_EDMA_1_1 = 53,
0256     GAUDI2_QUEUE_ID_DCORE1_EDMA_1_2 = 54,
0257     GAUDI2_QUEUE_ID_DCORE1_EDMA_1_3 = 55,
0258     GAUDI2_QUEUE_ID_DCORE1_MME_0_0 = 56,
0259     GAUDI2_QUEUE_ID_DCORE1_MME_0_1 = 57,
0260     GAUDI2_QUEUE_ID_DCORE1_MME_0_2 = 58,
0261     GAUDI2_QUEUE_ID_DCORE1_MME_0_3 = 59,
0262     GAUDI2_QUEUE_ID_DCORE1_TPC_0_0 = 60,
0263     GAUDI2_QUEUE_ID_DCORE1_TPC_0_1 = 61,
0264     GAUDI2_QUEUE_ID_DCORE1_TPC_0_2 = 62,
0265     GAUDI2_QUEUE_ID_DCORE1_TPC_0_3 = 63,
0266     GAUDI2_QUEUE_ID_DCORE1_TPC_1_0 = 64,
0267     GAUDI2_QUEUE_ID_DCORE1_TPC_1_1 = 65,
0268     GAUDI2_QUEUE_ID_DCORE1_TPC_1_2 = 66,
0269     GAUDI2_QUEUE_ID_DCORE1_TPC_1_3 = 67,
0270     GAUDI2_QUEUE_ID_DCORE1_TPC_2_0 = 68,
0271     GAUDI2_QUEUE_ID_DCORE1_TPC_2_1 = 69,
0272     GAUDI2_QUEUE_ID_DCORE1_TPC_2_2 = 70,
0273     GAUDI2_QUEUE_ID_DCORE1_TPC_2_3 = 71,
0274     GAUDI2_QUEUE_ID_DCORE1_TPC_3_0 = 72,
0275     GAUDI2_QUEUE_ID_DCORE1_TPC_3_1 = 73,
0276     GAUDI2_QUEUE_ID_DCORE1_TPC_3_2 = 74,
0277     GAUDI2_QUEUE_ID_DCORE1_TPC_3_3 = 75,
0278     GAUDI2_QUEUE_ID_DCORE1_TPC_4_0 = 76,
0279     GAUDI2_QUEUE_ID_DCORE1_TPC_4_1 = 77,
0280     GAUDI2_QUEUE_ID_DCORE1_TPC_4_2 = 78,
0281     GAUDI2_QUEUE_ID_DCORE1_TPC_4_3 = 79,
0282     GAUDI2_QUEUE_ID_DCORE1_TPC_5_0 = 80,
0283     GAUDI2_QUEUE_ID_DCORE1_TPC_5_1 = 81,
0284     GAUDI2_QUEUE_ID_DCORE1_TPC_5_2 = 82,
0285     GAUDI2_QUEUE_ID_DCORE1_TPC_5_3 = 83,
0286     GAUDI2_QUEUE_ID_DCORE2_EDMA_0_0 = 84,
0287     GAUDI2_QUEUE_ID_DCORE2_EDMA_0_1 = 85,
0288     GAUDI2_QUEUE_ID_DCORE2_EDMA_0_2 = 86,
0289     GAUDI2_QUEUE_ID_DCORE2_EDMA_0_3 = 87,
0290     GAUDI2_QUEUE_ID_DCORE2_EDMA_1_0 = 88,
0291     GAUDI2_QUEUE_ID_DCORE2_EDMA_1_1 = 89,
0292     GAUDI2_QUEUE_ID_DCORE2_EDMA_1_2 = 90,
0293     GAUDI2_QUEUE_ID_DCORE2_EDMA_1_3 = 91,
0294     GAUDI2_QUEUE_ID_DCORE2_MME_0_0 = 92,
0295     GAUDI2_QUEUE_ID_DCORE2_MME_0_1 = 93,
0296     GAUDI2_QUEUE_ID_DCORE2_MME_0_2 = 94,
0297     GAUDI2_QUEUE_ID_DCORE2_MME_0_3 = 95,
0298     GAUDI2_QUEUE_ID_DCORE2_TPC_0_0 = 96,
0299     GAUDI2_QUEUE_ID_DCORE2_TPC_0_1 = 97,
0300     GAUDI2_QUEUE_ID_DCORE2_TPC_0_2 = 98,
0301     GAUDI2_QUEUE_ID_DCORE2_TPC_0_3 = 99,
0302     GAUDI2_QUEUE_ID_DCORE2_TPC_1_0 = 100,
0303     GAUDI2_QUEUE_ID_DCORE2_TPC_1_1 = 101,
0304     GAUDI2_QUEUE_ID_DCORE2_TPC_1_2 = 102,
0305     GAUDI2_QUEUE_ID_DCORE2_TPC_1_3 = 103,
0306     GAUDI2_QUEUE_ID_DCORE2_TPC_2_0 = 104,
0307     GAUDI2_QUEUE_ID_DCORE2_TPC_2_1 = 105,
0308     GAUDI2_QUEUE_ID_DCORE2_TPC_2_2 = 106,
0309     GAUDI2_QUEUE_ID_DCORE2_TPC_2_3 = 107,
0310     GAUDI2_QUEUE_ID_DCORE2_TPC_3_0 = 108,
0311     GAUDI2_QUEUE_ID_DCORE2_TPC_3_1 = 109,
0312     GAUDI2_QUEUE_ID_DCORE2_TPC_3_2 = 110,
0313     GAUDI2_QUEUE_ID_DCORE2_TPC_3_3 = 111,
0314     GAUDI2_QUEUE_ID_DCORE2_TPC_4_0 = 112,
0315     GAUDI2_QUEUE_ID_DCORE2_TPC_4_1 = 113,
0316     GAUDI2_QUEUE_ID_DCORE2_TPC_4_2 = 114,
0317     GAUDI2_QUEUE_ID_DCORE2_TPC_4_3 = 115,
0318     GAUDI2_QUEUE_ID_DCORE2_TPC_5_0 = 116,
0319     GAUDI2_QUEUE_ID_DCORE2_TPC_5_1 = 117,
0320     GAUDI2_QUEUE_ID_DCORE2_TPC_5_2 = 118,
0321     GAUDI2_QUEUE_ID_DCORE2_TPC_5_3 = 119,
0322     GAUDI2_QUEUE_ID_DCORE3_EDMA_0_0 = 120,
0323     GAUDI2_QUEUE_ID_DCORE3_EDMA_0_1 = 121,
0324     GAUDI2_QUEUE_ID_DCORE3_EDMA_0_2 = 122,
0325     GAUDI2_QUEUE_ID_DCORE3_EDMA_0_3 = 123,
0326     GAUDI2_QUEUE_ID_DCORE3_EDMA_1_0 = 124,
0327     GAUDI2_QUEUE_ID_DCORE3_EDMA_1_1 = 125,
0328     GAUDI2_QUEUE_ID_DCORE3_EDMA_1_2 = 126,
0329     GAUDI2_QUEUE_ID_DCORE3_EDMA_1_3 = 127,
0330     GAUDI2_QUEUE_ID_DCORE3_MME_0_0 = 128,
0331     GAUDI2_QUEUE_ID_DCORE3_MME_0_1 = 129,
0332     GAUDI2_QUEUE_ID_DCORE3_MME_0_2 = 130,
0333     GAUDI2_QUEUE_ID_DCORE3_MME_0_3 = 131,
0334     GAUDI2_QUEUE_ID_DCORE3_TPC_0_0 = 132,
0335     GAUDI2_QUEUE_ID_DCORE3_TPC_0_1 = 133,
0336     GAUDI2_QUEUE_ID_DCORE3_TPC_0_2 = 134,
0337     GAUDI2_QUEUE_ID_DCORE3_TPC_0_3 = 135,
0338     GAUDI2_QUEUE_ID_DCORE3_TPC_1_0 = 136,
0339     GAUDI2_QUEUE_ID_DCORE3_TPC_1_1 = 137,
0340     GAUDI2_QUEUE_ID_DCORE3_TPC_1_2 = 138,
0341     GAUDI2_QUEUE_ID_DCORE3_TPC_1_3 = 139,
0342     GAUDI2_QUEUE_ID_DCORE3_TPC_2_0 = 140,
0343     GAUDI2_QUEUE_ID_DCORE3_TPC_2_1 = 141,
0344     GAUDI2_QUEUE_ID_DCORE3_TPC_2_2 = 142,
0345     GAUDI2_QUEUE_ID_DCORE3_TPC_2_3 = 143,
0346     GAUDI2_QUEUE_ID_DCORE3_TPC_3_0 = 144,
0347     GAUDI2_QUEUE_ID_DCORE3_TPC_3_1 = 145,
0348     GAUDI2_QUEUE_ID_DCORE3_TPC_3_2 = 146,
0349     GAUDI2_QUEUE_ID_DCORE3_TPC_3_3 = 147,
0350     GAUDI2_QUEUE_ID_DCORE3_TPC_4_0 = 148,
0351     GAUDI2_QUEUE_ID_DCORE3_TPC_4_1 = 149,
0352     GAUDI2_QUEUE_ID_DCORE3_TPC_4_2 = 150,
0353     GAUDI2_QUEUE_ID_DCORE3_TPC_4_3 = 151,
0354     GAUDI2_QUEUE_ID_DCORE3_TPC_5_0 = 152,
0355     GAUDI2_QUEUE_ID_DCORE3_TPC_5_1 = 153,
0356     GAUDI2_QUEUE_ID_DCORE3_TPC_5_2 = 154,
0357     GAUDI2_QUEUE_ID_DCORE3_TPC_5_3 = 155,
0358     GAUDI2_QUEUE_ID_NIC_0_0 = 156,
0359     GAUDI2_QUEUE_ID_NIC_0_1 = 157,
0360     GAUDI2_QUEUE_ID_NIC_0_2 = 158,
0361     GAUDI2_QUEUE_ID_NIC_0_3 = 159,
0362     GAUDI2_QUEUE_ID_NIC_1_0 = 160,
0363     GAUDI2_QUEUE_ID_NIC_1_1 = 161,
0364     GAUDI2_QUEUE_ID_NIC_1_2 = 162,
0365     GAUDI2_QUEUE_ID_NIC_1_3 = 163,
0366     GAUDI2_QUEUE_ID_NIC_2_0 = 164,
0367     GAUDI2_QUEUE_ID_NIC_2_1 = 165,
0368     GAUDI2_QUEUE_ID_NIC_2_2 = 166,
0369     GAUDI2_QUEUE_ID_NIC_2_3 = 167,
0370     GAUDI2_QUEUE_ID_NIC_3_0 = 168,
0371     GAUDI2_QUEUE_ID_NIC_3_1 = 169,
0372     GAUDI2_QUEUE_ID_NIC_3_2 = 170,
0373     GAUDI2_QUEUE_ID_NIC_3_3 = 171,
0374     GAUDI2_QUEUE_ID_NIC_4_0 = 172,
0375     GAUDI2_QUEUE_ID_NIC_4_1 = 173,
0376     GAUDI2_QUEUE_ID_NIC_4_2 = 174,
0377     GAUDI2_QUEUE_ID_NIC_4_3 = 175,
0378     GAUDI2_QUEUE_ID_NIC_5_0 = 176,
0379     GAUDI2_QUEUE_ID_NIC_5_1 = 177,
0380     GAUDI2_QUEUE_ID_NIC_5_2 = 178,
0381     GAUDI2_QUEUE_ID_NIC_5_3 = 179,
0382     GAUDI2_QUEUE_ID_NIC_6_0 = 180,
0383     GAUDI2_QUEUE_ID_NIC_6_1 = 181,
0384     GAUDI2_QUEUE_ID_NIC_6_2 = 182,
0385     GAUDI2_QUEUE_ID_NIC_6_3 = 183,
0386     GAUDI2_QUEUE_ID_NIC_7_0 = 184,
0387     GAUDI2_QUEUE_ID_NIC_7_1 = 185,
0388     GAUDI2_QUEUE_ID_NIC_7_2 = 186,
0389     GAUDI2_QUEUE_ID_NIC_7_3 = 187,
0390     GAUDI2_QUEUE_ID_NIC_8_0 = 188,
0391     GAUDI2_QUEUE_ID_NIC_8_1 = 189,
0392     GAUDI2_QUEUE_ID_NIC_8_2 = 190,
0393     GAUDI2_QUEUE_ID_NIC_8_3 = 191,
0394     GAUDI2_QUEUE_ID_NIC_9_0 = 192,
0395     GAUDI2_QUEUE_ID_NIC_9_1 = 193,
0396     GAUDI2_QUEUE_ID_NIC_9_2 = 194,
0397     GAUDI2_QUEUE_ID_NIC_9_3 = 195,
0398     GAUDI2_QUEUE_ID_NIC_10_0 = 196,
0399     GAUDI2_QUEUE_ID_NIC_10_1 = 197,
0400     GAUDI2_QUEUE_ID_NIC_10_2 = 198,
0401     GAUDI2_QUEUE_ID_NIC_10_3 = 199,
0402     GAUDI2_QUEUE_ID_NIC_11_0 = 200,
0403     GAUDI2_QUEUE_ID_NIC_11_1 = 201,
0404     GAUDI2_QUEUE_ID_NIC_11_2 = 202,
0405     GAUDI2_QUEUE_ID_NIC_11_3 = 203,
0406     GAUDI2_QUEUE_ID_NIC_12_0 = 204,
0407     GAUDI2_QUEUE_ID_NIC_12_1 = 205,
0408     GAUDI2_QUEUE_ID_NIC_12_2 = 206,
0409     GAUDI2_QUEUE_ID_NIC_12_3 = 207,
0410     GAUDI2_QUEUE_ID_NIC_13_0 = 208,
0411     GAUDI2_QUEUE_ID_NIC_13_1 = 209,
0412     GAUDI2_QUEUE_ID_NIC_13_2 = 210,
0413     GAUDI2_QUEUE_ID_NIC_13_3 = 211,
0414     GAUDI2_QUEUE_ID_NIC_14_0 = 212,
0415     GAUDI2_QUEUE_ID_NIC_14_1 = 213,
0416     GAUDI2_QUEUE_ID_NIC_14_2 = 214,
0417     GAUDI2_QUEUE_ID_NIC_14_3 = 215,
0418     GAUDI2_QUEUE_ID_NIC_15_0 = 216,
0419     GAUDI2_QUEUE_ID_NIC_15_1 = 217,
0420     GAUDI2_QUEUE_ID_NIC_15_2 = 218,
0421     GAUDI2_QUEUE_ID_NIC_15_3 = 219,
0422     GAUDI2_QUEUE_ID_NIC_16_0 = 220,
0423     GAUDI2_QUEUE_ID_NIC_16_1 = 221,
0424     GAUDI2_QUEUE_ID_NIC_16_2 = 222,
0425     GAUDI2_QUEUE_ID_NIC_16_3 = 223,
0426     GAUDI2_QUEUE_ID_NIC_17_0 = 224,
0427     GAUDI2_QUEUE_ID_NIC_17_1 = 225,
0428     GAUDI2_QUEUE_ID_NIC_17_2 = 226,
0429     GAUDI2_QUEUE_ID_NIC_17_3 = 227,
0430     GAUDI2_QUEUE_ID_NIC_18_0 = 228,
0431     GAUDI2_QUEUE_ID_NIC_18_1 = 229,
0432     GAUDI2_QUEUE_ID_NIC_18_2 = 230,
0433     GAUDI2_QUEUE_ID_NIC_18_3 = 231,
0434     GAUDI2_QUEUE_ID_NIC_19_0 = 232,
0435     GAUDI2_QUEUE_ID_NIC_19_1 = 233,
0436     GAUDI2_QUEUE_ID_NIC_19_2 = 234,
0437     GAUDI2_QUEUE_ID_NIC_19_3 = 235,
0438     GAUDI2_QUEUE_ID_NIC_20_0 = 236,
0439     GAUDI2_QUEUE_ID_NIC_20_1 = 237,
0440     GAUDI2_QUEUE_ID_NIC_20_2 = 238,
0441     GAUDI2_QUEUE_ID_NIC_20_3 = 239,
0442     GAUDI2_QUEUE_ID_NIC_21_0 = 240,
0443     GAUDI2_QUEUE_ID_NIC_21_1 = 241,
0444     GAUDI2_QUEUE_ID_NIC_21_2 = 242,
0445     GAUDI2_QUEUE_ID_NIC_21_3 = 243,
0446     GAUDI2_QUEUE_ID_NIC_22_0 = 244,
0447     GAUDI2_QUEUE_ID_NIC_22_1 = 245,
0448     GAUDI2_QUEUE_ID_NIC_22_2 = 246,
0449     GAUDI2_QUEUE_ID_NIC_22_3 = 247,
0450     GAUDI2_QUEUE_ID_NIC_23_0 = 248,
0451     GAUDI2_QUEUE_ID_NIC_23_1 = 249,
0452     GAUDI2_QUEUE_ID_NIC_23_2 = 250,
0453     GAUDI2_QUEUE_ID_NIC_23_3 = 251,
0454     GAUDI2_QUEUE_ID_ROT_0_0 = 252,
0455     GAUDI2_QUEUE_ID_ROT_0_1 = 253,
0456     GAUDI2_QUEUE_ID_ROT_0_2 = 254,
0457     GAUDI2_QUEUE_ID_ROT_0_3 = 255,
0458     GAUDI2_QUEUE_ID_ROT_1_0 = 256,
0459     GAUDI2_QUEUE_ID_ROT_1_1 = 257,
0460     GAUDI2_QUEUE_ID_ROT_1_2 = 258,
0461     GAUDI2_QUEUE_ID_ROT_1_3 = 259,
0462     GAUDI2_QUEUE_ID_CPU_PQ = 260,
0463     GAUDI2_QUEUE_ID_SIZE
0464 };
0465 
0466 /*
0467  * Engine Numbering
0468  *
0469  * Used in the "busy_engines_mask" field in `struct hl_info_hw_idle'
0470  */
0471 
0472 enum goya_engine_id {
0473     GOYA_ENGINE_ID_DMA_0 = 0,
0474     GOYA_ENGINE_ID_DMA_1,
0475     GOYA_ENGINE_ID_DMA_2,
0476     GOYA_ENGINE_ID_DMA_3,
0477     GOYA_ENGINE_ID_DMA_4,
0478     GOYA_ENGINE_ID_MME_0,
0479     GOYA_ENGINE_ID_TPC_0,
0480     GOYA_ENGINE_ID_TPC_1,
0481     GOYA_ENGINE_ID_TPC_2,
0482     GOYA_ENGINE_ID_TPC_3,
0483     GOYA_ENGINE_ID_TPC_4,
0484     GOYA_ENGINE_ID_TPC_5,
0485     GOYA_ENGINE_ID_TPC_6,
0486     GOYA_ENGINE_ID_TPC_7,
0487     GOYA_ENGINE_ID_SIZE
0488 };
0489 
0490 enum gaudi_engine_id {
0491     GAUDI_ENGINE_ID_DMA_0 = 0,
0492     GAUDI_ENGINE_ID_DMA_1,
0493     GAUDI_ENGINE_ID_DMA_2,
0494     GAUDI_ENGINE_ID_DMA_3,
0495     GAUDI_ENGINE_ID_DMA_4,
0496     GAUDI_ENGINE_ID_DMA_5,
0497     GAUDI_ENGINE_ID_DMA_6,
0498     GAUDI_ENGINE_ID_DMA_7,
0499     GAUDI_ENGINE_ID_MME_0,
0500     GAUDI_ENGINE_ID_MME_1,
0501     GAUDI_ENGINE_ID_MME_2,
0502     GAUDI_ENGINE_ID_MME_3,
0503     GAUDI_ENGINE_ID_TPC_0,
0504     GAUDI_ENGINE_ID_TPC_1,
0505     GAUDI_ENGINE_ID_TPC_2,
0506     GAUDI_ENGINE_ID_TPC_3,
0507     GAUDI_ENGINE_ID_TPC_4,
0508     GAUDI_ENGINE_ID_TPC_5,
0509     GAUDI_ENGINE_ID_TPC_6,
0510     GAUDI_ENGINE_ID_TPC_7,
0511     GAUDI_ENGINE_ID_NIC_0,
0512     GAUDI_ENGINE_ID_NIC_1,
0513     GAUDI_ENGINE_ID_NIC_2,
0514     GAUDI_ENGINE_ID_NIC_3,
0515     GAUDI_ENGINE_ID_NIC_4,
0516     GAUDI_ENGINE_ID_NIC_5,
0517     GAUDI_ENGINE_ID_NIC_6,
0518     GAUDI_ENGINE_ID_NIC_7,
0519     GAUDI_ENGINE_ID_NIC_8,
0520     GAUDI_ENGINE_ID_NIC_9,
0521     GAUDI_ENGINE_ID_SIZE
0522 };
0523 
0524 enum gaudi2_engine_id {
0525     GAUDI2_DCORE0_ENGINE_ID_EDMA_0 = 0,
0526     GAUDI2_DCORE0_ENGINE_ID_EDMA_1,
0527     GAUDI2_DCORE0_ENGINE_ID_MME,
0528     GAUDI2_DCORE0_ENGINE_ID_TPC_0,
0529     GAUDI2_DCORE0_ENGINE_ID_TPC_1,
0530     GAUDI2_DCORE0_ENGINE_ID_TPC_2,
0531     GAUDI2_DCORE0_ENGINE_ID_TPC_3,
0532     GAUDI2_DCORE0_ENGINE_ID_TPC_4,
0533     GAUDI2_DCORE0_ENGINE_ID_TPC_5,
0534     GAUDI2_DCORE0_ENGINE_ID_DEC_0,
0535     GAUDI2_DCORE0_ENGINE_ID_DEC_1,
0536     GAUDI2_DCORE1_ENGINE_ID_EDMA_0,
0537     GAUDI2_DCORE1_ENGINE_ID_EDMA_1,
0538     GAUDI2_DCORE1_ENGINE_ID_MME,
0539     GAUDI2_DCORE1_ENGINE_ID_TPC_0,
0540     GAUDI2_DCORE1_ENGINE_ID_TPC_1,
0541     GAUDI2_DCORE1_ENGINE_ID_TPC_2,
0542     GAUDI2_DCORE1_ENGINE_ID_TPC_3,
0543     GAUDI2_DCORE1_ENGINE_ID_TPC_4,
0544     GAUDI2_DCORE1_ENGINE_ID_TPC_5,
0545     GAUDI2_DCORE1_ENGINE_ID_DEC_0,
0546     GAUDI2_DCORE1_ENGINE_ID_DEC_1,
0547     GAUDI2_DCORE2_ENGINE_ID_EDMA_0,
0548     GAUDI2_DCORE2_ENGINE_ID_EDMA_1,
0549     GAUDI2_DCORE2_ENGINE_ID_MME,
0550     GAUDI2_DCORE2_ENGINE_ID_TPC_0,
0551     GAUDI2_DCORE2_ENGINE_ID_TPC_1,
0552     GAUDI2_DCORE2_ENGINE_ID_TPC_2,
0553     GAUDI2_DCORE2_ENGINE_ID_TPC_3,
0554     GAUDI2_DCORE2_ENGINE_ID_TPC_4,
0555     GAUDI2_DCORE2_ENGINE_ID_TPC_5,
0556     GAUDI2_DCORE2_ENGINE_ID_DEC_0,
0557     GAUDI2_DCORE2_ENGINE_ID_DEC_1,
0558     GAUDI2_DCORE3_ENGINE_ID_EDMA_0,
0559     GAUDI2_DCORE3_ENGINE_ID_EDMA_1,
0560     GAUDI2_DCORE3_ENGINE_ID_MME,
0561     GAUDI2_DCORE3_ENGINE_ID_TPC_0,
0562     GAUDI2_DCORE3_ENGINE_ID_TPC_1,
0563     GAUDI2_DCORE3_ENGINE_ID_TPC_2,
0564     GAUDI2_DCORE3_ENGINE_ID_TPC_3,
0565     GAUDI2_DCORE3_ENGINE_ID_TPC_4,
0566     GAUDI2_DCORE3_ENGINE_ID_TPC_5,
0567     GAUDI2_DCORE3_ENGINE_ID_DEC_0,
0568     GAUDI2_DCORE3_ENGINE_ID_DEC_1,
0569     GAUDI2_DCORE0_ENGINE_ID_TPC_6,
0570     GAUDI2_ENGINE_ID_PDMA_0,
0571     GAUDI2_ENGINE_ID_PDMA_1,
0572     GAUDI2_ENGINE_ID_ROT_0,
0573     GAUDI2_ENGINE_ID_ROT_1,
0574     GAUDI2_PCIE_ENGINE_ID_DEC_0,
0575     GAUDI2_PCIE_ENGINE_ID_DEC_1,
0576     GAUDI2_ENGINE_ID_NIC0_0,
0577     GAUDI2_ENGINE_ID_NIC0_1,
0578     GAUDI2_ENGINE_ID_NIC1_0,
0579     GAUDI2_ENGINE_ID_NIC1_1,
0580     GAUDI2_ENGINE_ID_NIC2_0,
0581     GAUDI2_ENGINE_ID_NIC2_1,
0582     GAUDI2_ENGINE_ID_NIC3_0,
0583     GAUDI2_ENGINE_ID_NIC3_1,
0584     GAUDI2_ENGINE_ID_NIC4_0,
0585     GAUDI2_ENGINE_ID_NIC4_1,
0586     GAUDI2_ENGINE_ID_NIC5_0,
0587     GAUDI2_ENGINE_ID_NIC5_1,
0588     GAUDI2_ENGINE_ID_NIC6_0,
0589     GAUDI2_ENGINE_ID_NIC6_1,
0590     GAUDI2_ENGINE_ID_NIC7_0,
0591     GAUDI2_ENGINE_ID_NIC7_1,
0592     GAUDI2_ENGINE_ID_NIC8_0,
0593     GAUDI2_ENGINE_ID_NIC8_1,
0594     GAUDI2_ENGINE_ID_NIC9_0,
0595     GAUDI2_ENGINE_ID_NIC9_1,
0596     GAUDI2_ENGINE_ID_NIC10_0,
0597     GAUDI2_ENGINE_ID_NIC10_1,
0598     GAUDI2_ENGINE_ID_NIC11_0,
0599     GAUDI2_ENGINE_ID_NIC11_1,
0600     GAUDI2_ENGINE_ID_SIZE
0601 };
0602 
0603 /*
0604  * ASIC specific PLL index
0605  *
0606  * Used to retrieve in frequency info of different IPs via
0607  * HL_INFO_PLL_FREQUENCY under HL_IOCTL_INFO IOCTL. The enums need to be
0608  * used as an index in struct hl_pll_frequency_info
0609  */
0610 
0611 enum hl_goya_pll_index {
0612     HL_GOYA_CPU_PLL = 0,
0613     HL_GOYA_IC_PLL,
0614     HL_GOYA_MC_PLL,
0615     HL_GOYA_MME_PLL,
0616     HL_GOYA_PCI_PLL,
0617     HL_GOYA_EMMC_PLL,
0618     HL_GOYA_TPC_PLL,
0619     HL_GOYA_PLL_MAX
0620 };
0621 
0622 enum hl_gaudi_pll_index {
0623     HL_GAUDI_CPU_PLL = 0,
0624     HL_GAUDI_PCI_PLL,
0625     HL_GAUDI_SRAM_PLL,
0626     HL_GAUDI_HBM_PLL,
0627     HL_GAUDI_NIC_PLL,
0628     HL_GAUDI_DMA_PLL,
0629     HL_GAUDI_MESH_PLL,
0630     HL_GAUDI_MME_PLL,
0631     HL_GAUDI_TPC_PLL,
0632     HL_GAUDI_IF_PLL,
0633     HL_GAUDI_PLL_MAX
0634 };
0635 
0636 enum hl_gaudi2_pll_index {
0637     HL_GAUDI2_CPU_PLL = 0,
0638     HL_GAUDI2_PCI_PLL,
0639     HL_GAUDI2_SRAM_PLL,
0640     HL_GAUDI2_HBM_PLL,
0641     HL_GAUDI2_NIC_PLL,
0642     HL_GAUDI2_DMA_PLL,
0643     HL_GAUDI2_MESH_PLL,
0644     HL_GAUDI2_MME_PLL,
0645     HL_GAUDI2_TPC_PLL,
0646     HL_GAUDI2_IF_PLL,
0647     HL_GAUDI2_VID_PLL,
0648     HL_GAUDI2_MSS_PLL,
0649     HL_GAUDI2_PLL_MAX
0650 };
0651 
0652 /**
0653  * enum hl_goya_dma_direction - Direction of DMA operation inside a LIN_DMA packet that is
0654  *                              submitted to the GOYA's DMA QMAN. This attribute is not relevant
0655  *                              to the H/W but the kernel driver use it to parse the packet's
0656  *                              addresses and patch/validate them.
0657  * @HL_DMA_HOST_TO_DRAM: DMA operation from Host memory to GOYA's DDR.
0658  * @HL_DMA_HOST_TO_SRAM: DMA operation from Host memory to GOYA's SRAM.
0659  * @HL_DMA_DRAM_TO_SRAM: DMA operation from GOYA's DDR to GOYA's SRAM.
0660  * @HL_DMA_SRAM_TO_DRAM: DMA operation from GOYA's SRAM to GOYA's DDR.
0661  * @HL_DMA_SRAM_TO_HOST: DMA operation from GOYA's SRAM to Host memory.
0662  * @HL_DMA_DRAM_TO_HOST: DMA operation from GOYA's DDR to Host memory.
0663  * @HL_DMA_DRAM_TO_DRAM: DMA operation from GOYA's DDR to GOYA's DDR.
0664  * @HL_DMA_SRAM_TO_SRAM: DMA operation from GOYA's SRAM to GOYA's SRAM.
0665  * @HL_DMA_ENUM_MAX: number of values in enum
0666  */
0667 enum hl_goya_dma_direction {
0668     HL_DMA_HOST_TO_DRAM,
0669     HL_DMA_HOST_TO_SRAM,
0670     HL_DMA_DRAM_TO_SRAM,
0671     HL_DMA_SRAM_TO_DRAM,
0672     HL_DMA_SRAM_TO_HOST,
0673     HL_DMA_DRAM_TO_HOST,
0674     HL_DMA_DRAM_TO_DRAM,
0675     HL_DMA_SRAM_TO_SRAM,
0676     HL_DMA_ENUM_MAX
0677 };
0678 
0679 /**
0680  * enum hl_device_status - Device status information.
0681  * @HL_DEVICE_STATUS_OPERATIONAL: Device is operational.
0682  * @HL_DEVICE_STATUS_IN_RESET: Device is currently during reset.
0683  * @HL_DEVICE_STATUS_MALFUNCTION: Device is unusable.
0684  * @HL_DEVICE_STATUS_NEEDS_RESET: Device needs reset because auto reset was disabled.
0685  * @HL_DEVICE_STATUS_IN_DEVICE_CREATION: Device is operational but its creation is still in
0686  *                                       progress.
0687  * @HL_DEVICE_STATUS_IN_RESET_AFTER_DEVICE_RELEASE: Device is currently during reset that was
0688  *                                                  triggered because the user released the device
0689  * @HL_DEVICE_STATUS_LAST: Last status.
0690  */
0691 enum hl_device_status {
0692     HL_DEVICE_STATUS_OPERATIONAL,
0693     HL_DEVICE_STATUS_IN_RESET,
0694     HL_DEVICE_STATUS_MALFUNCTION,
0695     HL_DEVICE_STATUS_NEEDS_RESET,
0696     HL_DEVICE_STATUS_IN_DEVICE_CREATION,
0697     HL_DEVICE_STATUS_IN_RESET_AFTER_DEVICE_RELEASE,
0698     HL_DEVICE_STATUS_LAST = HL_DEVICE_STATUS_IN_RESET_AFTER_DEVICE_RELEASE
0699 };
0700 
0701 enum hl_server_type {
0702     HL_SERVER_TYPE_UNKNOWN = 0,
0703     HL_SERVER_GAUDI_HLS1 = 1,
0704     HL_SERVER_GAUDI_HLS1H = 2,
0705     HL_SERVER_GAUDI_TYPE1 = 3,
0706     HL_SERVER_GAUDI_TYPE2 = 4,
0707     HL_SERVER_GAUDI2_HLS2 = 5
0708 };
0709 
0710 /* Opcode for management ioctl
0711  *
0712  * HW_IP_INFO            - Receive information about different IP blocks in the
0713  *                         device.
0714  * HL_INFO_HW_EVENTS     - Receive an array describing how many times each event
0715  *                         occurred since the last hard reset.
0716  * HL_INFO_DRAM_USAGE    - Retrieve the dram usage inside the device and of the
0717  *                         specific context. This is relevant only for devices
0718  *                         where the dram is managed by the kernel driver
0719  * HL_INFO_HW_IDLE       - Retrieve information about the idle status of each
0720  *                         internal engine.
0721  * HL_INFO_DEVICE_STATUS - Retrieve the device's status. This opcode doesn't
0722  *                         require an open context.
0723  * HL_INFO_DEVICE_UTILIZATION  - Retrieve the total utilization of the device
0724  *                               over the last period specified by the user.
0725  *                               The period can be between 100ms to 1s, in
0726  *                               resolution of 100ms. The return value is a
0727  *                               percentage of the utilization rate.
0728  * HL_INFO_HW_EVENTS_AGGREGATE - Receive an array describing how many times each
0729  *                               event occurred since the driver was loaded.
0730  * HL_INFO_CLK_RATE            - Retrieve the current and maximum clock rate
0731  *                               of the device in MHz. The maximum clock rate is
0732  *                               configurable via sysfs parameter
0733  * HL_INFO_RESET_COUNT   - Retrieve the counts of the soft and hard reset
0734  *                         operations performed on the device since the last
0735  *                         time the driver was loaded.
0736  * HL_INFO_TIME_SYNC     - Retrieve the device's time alongside the host's time
0737  *                         for synchronization.
0738  * HL_INFO_CS_COUNTERS   - Retrieve command submission counters
0739  * HL_INFO_PCI_COUNTERS  - Retrieve PCI counters
0740  * HL_INFO_CLK_THROTTLE_REASON - Retrieve clock throttling reason
0741  * HL_INFO_SYNC_MANAGER  - Retrieve sync manager info per dcore
0742  * HL_INFO_TOTAL_ENERGY  - Retrieve total energy consumption
0743  * HL_INFO_PLL_FREQUENCY - Retrieve PLL frequency
0744  * HL_INFO_POWER         - Retrieve power information
0745  * HL_INFO_OPEN_STATS    - Retrieve info regarding recent device open calls
0746  * HL_INFO_DRAM_REPLACED_ROWS - Retrieve DRAM replaced rows info
0747  * HL_INFO_DRAM_PENDING_ROWS - Retrieve DRAM pending rows num
0748  * HL_INFO_LAST_ERR_OPEN_DEV_TIME - Retrieve timestamp of the last time the device was opened
0749  *                                  and CS timeout or razwi error occurred.
0750  * HL_INFO_CS_TIMEOUT_EVENT - Retrieve CS timeout timestamp and its related CS sequence number.
0751  * HL_INFO_RAZWI_EVENT - Retrieve parameters of razwi:
0752  *                            Timestamp of razwi.
0753  *                            The address which accessing it caused the razwi.
0754  *                            Razwi initiator.
0755  *                            Razwi cause, was it a page fault or MMU access error.
0756  * HL_INFO_DEV_MEM_ALLOC_PAGE_SIZES - Retrieve valid page sizes for device memory allocation
0757  * HL_INFO_REGISTER_EVENTFD   - Register eventfd for event notifications.
0758  * HL_INFO_UNREGISTER_EVENTFD - Unregister eventfd
0759  * HL_INFO_GET_EVENTS         - Retrieve the last occurred events
0760  * HL_INFO_UNDEFINED_OPCODE_EVENT - Retrieve last undefined opcode error information.
0761  */
0762 #define HL_INFO_HW_IP_INFO          0
0763 #define HL_INFO_HW_EVENTS           1
0764 #define HL_INFO_DRAM_USAGE          2
0765 #define HL_INFO_HW_IDLE             3
0766 #define HL_INFO_DEVICE_STATUS           4
0767 #define HL_INFO_DEVICE_UTILIZATION      6
0768 #define HL_INFO_HW_EVENTS_AGGREGATE     7
0769 #define HL_INFO_CLK_RATE            8
0770 #define HL_INFO_RESET_COUNT         9
0771 #define HL_INFO_TIME_SYNC           10
0772 #define HL_INFO_CS_COUNTERS         11
0773 #define HL_INFO_PCI_COUNTERS            12
0774 #define HL_INFO_CLK_THROTTLE_REASON     13
0775 #define HL_INFO_SYNC_MANAGER            14
0776 #define HL_INFO_TOTAL_ENERGY            15
0777 #define HL_INFO_PLL_FREQUENCY           16
0778 #define HL_INFO_POWER               17
0779 #define HL_INFO_OPEN_STATS          18
0780 #define HL_INFO_DRAM_REPLACED_ROWS      21
0781 #define HL_INFO_DRAM_PENDING_ROWS       22
0782 #define HL_INFO_LAST_ERR_OPEN_DEV_TIME      23
0783 #define HL_INFO_CS_TIMEOUT_EVENT        24
0784 #define HL_INFO_RAZWI_EVENT         25
0785 #define HL_INFO_DEV_MEM_ALLOC_PAGE_SIZES    26
0786 #define HL_INFO_REGISTER_EVENTFD        28
0787 #define HL_INFO_UNREGISTER_EVENTFD      29
0788 #define HL_INFO_GET_EVENTS          30
0789 #define HL_INFO_UNDEFINED_OPCODE_EVENT      31
0790 
0791 #define HL_INFO_VERSION_MAX_LEN         128
0792 #define HL_INFO_CARD_NAME_MAX_LEN       16
0793 
0794 /**
0795  * struct hl_info_hw_ip_info - hardware information on various IPs in the ASIC
0796  * @sram_base_address: The first SRAM physical base address that is free to be
0797  *                     used by the user.
0798  * @dram_base_address: The first DRAM virtual or physical base address that is
0799  *                     free to be used by the user.
0800  * @dram_size: The DRAM size that is available to the user.
0801  * @sram_size: The SRAM size that is available to the user.
0802  * @num_of_events: The number of events that can be received from the f/w. This
0803  *                 is needed so the user can what is the size of the h/w events
0804  *                 array he needs to pass to the kernel when he wants to fetch
0805  *                 the event counters.
0806  * @device_id: PCI device ID of the ASIC.
0807  * @module_id: Module ID of the ASIC for mezzanine cards in servers
0808  *             (From OCP spec).
0809  * @decoder_enabled_mask: Bit-mask that represents which decoders are enabled.
0810  * @first_available_interrupt_id: The first available interrupt ID for the user
0811  *                                to be used when it works with user interrupts.
0812  *                                Relevant for Gaudi2 and later.
0813  * @server_type: Server type that the Gaudi ASIC is currently installed in.
0814  *               The value is according to enum hl_server_type
0815  * @cpld_version: CPLD version on the board.
0816  * @psoc_pci_pll_nr: PCI PLL NR value. Needed by the profiler in some ASICs.
0817  * @psoc_pci_pll_nf: PCI PLL NF value. Needed by the profiler in some ASICs.
0818  * @psoc_pci_pll_od: PCI PLL OD value. Needed by the profiler in some ASICs.
0819  * @psoc_pci_pll_div_factor: PCI PLL DIV factor value. Needed by the profiler
0820  *                           in some ASICs.
0821  * @tpc_enabled_mask: Bit-mask that represents which TPCs are enabled. Relevant
0822  *                    for Goya/Gaudi only.
0823  * @dram_enabled: Whether the DRAM is enabled.
0824  * @mme_master_slave_mode: Indicate whether the MME is working in master/slave
0825  *                         configuration. Relevant for Greco and later.
0826  * @cpucp_version: The CPUCP f/w version.
0827  * @card_name: The card name as passed by the f/w.
0828  * @tpc_enabled_mask_ext: Bit-mask that represents which TPCs are enabled.
0829  *                        Relevant for Greco and later.
0830  * @dram_page_size: The DRAM physical page size.
0831  * @edma_enabled_mask: Bit-mask that represents which EDMAs are enabled.
0832  *                     Relevant for Gaudi2 and later.
0833  * @number_of_user_interrupts: The number of interrupts that are available to the userspace
0834  *                             application to use. Relevant for Gaudi2 and later.
0835  * @device_mem_alloc_default_page_size: default page size used in device memory allocation.
0836  */
0837 struct hl_info_hw_ip_info {
0838     __u64 sram_base_address;
0839     __u64 dram_base_address;
0840     __u64 dram_size;
0841     __u32 sram_size;
0842     __u32 num_of_events;
0843     __u32 device_id;
0844     __u32 module_id;
0845     __u32 decoder_enabled_mask;
0846     __u16 first_available_interrupt_id;
0847     __u16 server_type;
0848     __u32 cpld_version;
0849     __u32 psoc_pci_pll_nr;
0850     __u32 psoc_pci_pll_nf;
0851     __u32 psoc_pci_pll_od;
0852     __u32 psoc_pci_pll_div_factor;
0853     __u8 tpc_enabled_mask;
0854     __u8 dram_enabled;
0855     __u8 reserved;
0856     __u8 mme_master_slave_mode;
0857     __u8 cpucp_version[HL_INFO_VERSION_MAX_LEN];
0858     __u8 card_name[HL_INFO_CARD_NAME_MAX_LEN];
0859     __u64 tpc_enabled_mask_ext;
0860     __u64 dram_page_size;
0861     __u32 edma_enabled_mask;
0862     __u16 number_of_user_interrupts;
0863     __u16 pad2;
0864     __u64 reserved4;
0865     __u64 device_mem_alloc_default_page_size;
0866 };
0867 
0868 struct hl_info_dram_usage {
0869     __u64 dram_free_mem;
0870     __u64 ctx_dram_mem;
0871 };
0872 
0873 #define HL_BUSY_ENGINES_MASK_EXT_SIZE   2
0874 
0875 struct hl_info_hw_idle {
0876     __u32 is_idle;
0877     /*
0878      * Bitmask of busy engines.
0879      * Bits definition is according to `enum <chip>_enging_id'.
0880      */
0881     __u32 busy_engines_mask;
0882 
0883     /*
0884      * Extended Bitmask of busy engines.
0885      * Bits definition is according to `enum <chip>_enging_id'.
0886      */
0887     __u64 busy_engines_mask_ext[HL_BUSY_ENGINES_MASK_EXT_SIZE];
0888 };
0889 
0890 struct hl_info_device_status {
0891     __u32 status;
0892     __u32 pad;
0893 };
0894 
0895 struct hl_info_device_utilization {
0896     __u32 utilization;
0897     __u32 pad;
0898 };
0899 
0900 struct hl_info_clk_rate {
0901     __u32 cur_clk_rate_mhz;
0902     __u32 max_clk_rate_mhz;
0903 };
0904 
0905 struct hl_info_reset_count {
0906     __u32 hard_reset_cnt;
0907     __u32 soft_reset_cnt;
0908 };
0909 
0910 struct hl_info_time_sync {
0911     __u64 device_time;
0912     __u64 host_time;
0913 };
0914 
0915 /**
0916  * struct hl_info_pci_counters - pci counters
0917  * @rx_throughput: PCI rx throughput KBps
0918  * @tx_throughput: PCI tx throughput KBps
0919  * @replay_cnt: PCI replay counter
0920  */
0921 struct hl_info_pci_counters {
0922     __u64 rx_throughput;
0923     __u64 tx_throughput;
0924     __u64 replay_cnt;
0925 };
0926 
0927 enum hl_clk_throttling_type {
0928     HL_CLK_THROTTLE_TYPE_POWER,
0929     HL_CLK_THROTTLE_TYPE_THERMAL,
0930     HL_CLK_THROTTLE_TYPE_MAX
0931 };
0932 
0933 /* clk_throttling_reason masks */
0934 #define HL_CLK_THROTTLE_POWER       (1 << HL_CLK_THROTTLE_TYPE_POWER)
0935 #define HL_CLK_THROTTLE_THERMAL     (1 << HL_CLK_THROTTLE_TYPE_THERMAL)
0936 
0937 /**
0938  * struct hl_info_clk_throttle - clock throttling reason
0939  * @clk_throttling_reason: each bit represents a clk throttling reason
0940  * @clk_throttling_timestamp_us: represents CPU timestamp in microseconds of the start-event
0941  * @clk_throttling_duration_ns: the clock throttle time in nanosec
0942  */
0943 struct hl_info_clk_throttle {
0944     __u32 clk_throttling_reason;
0945     __u32 pad;
0946     __u64 clk_throttling_timestamp_us[HL_CLK_THROTTLE_TYPE_MAX];
0947     __u64 clk_throttling_duration_ns[HL_CLK_THROTTLE_TYPE_MAX];
0948 };
0949 
0950 /**
0951  * struct hl_info_energy - device energy information
0952  * @total_energy_consumption: total device energy consumption
0953  */
0954 struct hl_info_energy {
0955     __u64 total_energy_consumption;
0956 };
0957 
0958 #define HL_PLL_NUM_OUTPUTS 4
0959 
0960 struct hl_pll_frequency_info {
0961     __u16 output[HL_PLL_NUM_OUTPUTS];
0962 };
0963 
0964 /**
0965  * struct hl_open_stats_info - device open statistics information
0966  * @open_counter: ever growing counter, increased on each successful dev open
0967  * @last_open_period_ms: duration (ms) device was open last time
0968  * @is_compute_ctx_active: Whether there is an active compute context executing
0969  * @compute_ctx_in_release: true if the current compute context is being released
0970  */
0971 struct hl_open_stats_info {
0972     __u64 open_counter;
0973     __u64 last_open_period_ms;
0974     __u8 is_compute_ctx_active;
0975     __u8 compute_ctx_in_release;
0976     __u8 pad[6];
0977 };
0978 
0979 /**
0980  * struct hl_power_info - power information
0981  * @power: power consumption
0982  */
0983 struct hl_power_info {
0984     __u64 power;
0985 };
0986 
0987 /**
0988  * struct hl_info_sync_manager - sync manager information
0989  * @first_available_sync_object: first available sob
0990  * @first_available_monitor: first available monitor
0991  * @first_available_cq: first available cq
0992  */
0993 struct hl_info_sync_manager {
0994     __u32 first_available_sync_object;
0995     __u32 first_available_monitor;
0996     __u32 first_available_cq;
0997     __u32 reserved;
0998 };
0999 
1000 /**
1001  * struct hl_info_cs_counters - command submission counters
1002  * @total_out_of_mem_drop_cnt: total dropped due to memory allocation issue
1003  * @ctx_out_of_mem_drop_cnt: context dropped due to memory allocation issue
1004  * @total_parsing_drop_cnt: total dropped due to error in packet parsing
1005  * @ctx_parsing_drop_cnt: context dropped due to error in packet parsing
1006  * @total_queue_full_drop_cnt: total dropped due to queue full
1007  * @ctx_queue_full_drop_cnt: context dropped due to queue full
1008  * @total_device_in_reset_drop_cnt: total dropped due to device in reset
1009  * @ctx_device_in_reset_drop_cnt: context dropped due to device in reset
1010  * @total_max_cs_in_flight_drop_cnt: total dropped due to maximum CS in-flight
1011  * @ctx_max_cs_in_flight_drop_cnt: context dropped due to maximum CS in-flight
1012  * @total_validation_drop_cnt: total dropped due to validation error
1013  * @ctx_validation_drop_cnt: context dropped due to validation error
1014  */
1015 struct hl_info_cs_counters {
1016     __u64 total_out_of_mem_drop_cnt;
1017     __u64 ctx_out_of_mem_drop_cnt;
1018     __u64 total_parsing_drop_cnt;
1019     __u64 ctx_parsing_drop_cnt;
1020     __u64 total_queue_full_drop_cnt;
1021     __u64 ctx_queue_full_drop_cnt;
1022     __u64 total_device_in_reset_drop_cnt;
1023     __u64 ctx_device_in_reset_drop_cnt;
1024     __u64 total_max_cs_in_flight_drop_cnt;
1025     __u64 ctx_max_cs_in_flight_drop_cnt;
1026     __u64 total_validation_drop_cnt;
1027     __u64 ctx_validation_drop_cnt;
1028 };
1029 
1030 /**
1031  * struct hl_info_last_err_open_dev_time - last error boot information.
1032  * @timestamp: timestamp of last time the device was opened and error occurred.
1033  */
1034 struct hl_info_last_err_open_dev_time {
1035     __s64 timestamp;
1036 };
1037 
1038 /**
1039  * struct hl_info_cs_timeout_event - last CS timeout information.
1040  * @timestamp: timestamp when last CS timeout event occurred.
1041  * @seq: sequence number of last CS timeout event.
1042  */
1043 struct hl_info_cs_timeout_event {
1044     __s64 timestamp;
1045     __u64 seq;
1046 };
1047 
1048 #define HL_RAZWI_PAGE_FAULT 0
1049 #define HL_RAZWI_MMU_ACCESS_ERROR 1
1050 
1051 /**
1052  * struct hl_info_razwi_event - razwi information.
1053  * @timestamp: timestamp of razwi.
1054  * @addr: address which accessing it caused razwi.
1055  * @engine_id_1: engine id of the razwi initiator, if it was initiated by engine that does not
1056  *               have engine id it will be set to U16_MAX.
1057  * @engine_id_2: second engine id of razwi initiator. Might happen that razwi have 2 possible
1058  *               engines which one them caused the razwi. In that case, it will contain the
1059  *               second possible engine id, otherwise it will be set to U16_MAX.
1060  * @no_engine_id: if razwi initiator does not have engine id, this field will be set to 1,
1061  *                otherwise 0.
1062  * @error_type: cause of razwi, page fault or access error, otherwise it will be set to U8_MAX.
1063  * @pad: padding to 64 bit.
1064  */
1065 struct hl_info_razwi_event {
1066     __s64 timestamp;
1067     __u64 addr;
1068     __u16 engine_id_1;
1069     __u16 engine_id_2;
1070     __u8 no_engine_id;
1071     __u8 error_type;
1072     __u8 pad[2];
1073 };
1074 
1075 #define MAX_QMAN_STREAMS_INFO       4
1076 #define OPCODE_INFO_MAX_ADDR_SIZE   8
1077 /**
1078  * struct hl_info_undefined_opcode_event - info about last undefined opcode error
1079  * @timestamp: timestamp of the undefined opcode error
1080  * @cb_addr_streams: CB addresses (per stream) that are currently exists in the PQ
1081  *                   entiers. In case all streams array entries are
1082  *                   filled with values, it means the execution was in Lower-CP.
1083  * @cq_addr: the address of the current handled command buffer
1084  * @cq_size: the size of the current handled command buffer
1085  * @cb_addr_streams_len: num of streams - actual len of cb_addr_streams array.
1086  *                       should be equal to 1 incase of undefined opcode
1087  *                       in Upper-CP (specific stream) and equal to 4 incase
1088  *                       of undefined opcode in Lower-CP.
1089  * @engine_id: engine-id that the error occurred on
1090  * @stream_id: the stream id the error occurred on. In case the stream equals to
1091  *             MAX_QMAN_STREAMS_INFO it means the error occurred on a Lower-CP.
1092  */
1093 struct hl_info_undefined_opcode_event {
1094     __s64 timestamp;
1095     __u64 cb_addr_streams[MAX_QMAN_STREAMS_INFO][OPCODE_INFO_MAX_ADDR_SIZE];
1096     __u64 cq_addr;
1097     __u32 cq_size;
1098     __u32 cb_addr_streams_len;
1099     __u32 engine_id;
1100     __u32 stream_id;
1101 };
1102 
1103 /**
1104  * struct hl_info_dev_memalloc_page_sizes - valid page sizes in device mem alloc information.
1105  * @page_order_bitmask: bitmap in which a set bit represents the order of the supported page size
1106  *                      (e.g. 0x2100000 means that 1MB and 32MB pages are supported).
1107  */
1108 struct hl_info_dev_memalloc_page_sizes {
1109     __u64 page_order_bitmask;
1110 };
1111 
1112 enum gaudi_dcores {
1113     HL_GAUDI_WS_DCORE,
1114     HL_GAUDI_WN_DCORE,
1115     HL_GAUDI_EN_DCORE,
1116     HL_GAUDI_ES_DCORE
1117 };
1118 
1119 /**
1120  * struct hl_info_args - Main structure to retrieve device related information.
1121  * @return_pointer: User space address of the relevant structure related to HL_INFO_* operation
1122  *                  mentioned in @op.
1123  * @return_size: Size of the structure used in @return_pointer, just like "size" in "snprintf", it
1124  *               limits how many bytes the kernel can write. For hw_events array, the size should be
1125  *               hl_info_hw_ip_info.num_of_events * sizeof(__u32).
1126  * @op: Defines which type of information to be retrieved. Refer HL_INFO_* for details.
1127  * @dcore_id: DCORE id for which the information is relevant (for Gaudi refer to enum gaudi_dcores).
1128  * @ctx_id: Context ID of the user. Currently not in use.
1129  * @period_ms: Period value, in milliseconds, for utilization rate in range 100ms - 1000ms in 100 ms
1130  *             resolution. Currently not in use.
1131  * @pll_index: Index as defined in hl_<asic type>_pll_index enumeration.
1132  * @eventfd: event file descriptor for event notifications.
1133  * @pad: Padding to 64 bit.
1134  */
1135 struct hl_info_args {
1136     __u64 return_pointer;
1137     __u32 return_size;
1138     __u32 op;
1139 
1140     union {
1141         __u32 dcore_id;
1142         __u32 ctx_id;
1143         __u32 period_ms;
1144         __u32 pll_index;
1145         __u32 eventfd;
1146     };
1147 
1148     __u32 pad;
1149 };
1150 
1151 /* Opcode to create a new command buffer */
1152 #define HL_CB_OP_CREATE     0
1153 /* Opcode to destroy previously created command buffer */
1154 #define HL_CB_OP_DESTROY    1
1155 /* Opcode to retrieve information about a command buffer */
1156 #define HL_CB_OP_INFO       2
1157 
1158 /* 2MB minus 32 bytes for 2xMSG_PROT */
1159 #define HL_MAX_CB_SIZE      (0x200000 - 32)
1160 
1161 /* Indicates whether the command buffer should be mapped to the device's MMU */
1162 #define HL_CB_FLAGS_MAP         0x1
1163 
1164 /* Used with HL_CB_OP_INFO opcode to get the device va address for kernel mapped CB */
1165 #define HL_CB_FLAGS_GET_DEVICE_VA   0x2
1166 
1167 struct hl_cb_in {
1168     /* Handle of CB or 0 if we want to create one */
1169     __u64 cb_handle;
1170     /* HL_CB_OP_* */
1171     __u32 op;
1172 
1173     /* Size of CB. Maximum size is HL_MAX_CB_SIZE. The minimum size that
1174      * will be allocated, regardless of this parameter's value, is PAGE_SIZE
1175      */
1176     __u32 cb_size;
1177 
1178     /* Context ID - Currently not in use */
1179     __u32 ctx_id;
1180     /* HL_CB_FLAGS_* */
1181     __u32 flags;
1182 };
1183 
1184 struct hl_cb_out {
1185     union {
1186         /* Handle of CB */
1187         __u64 cb_handle;
1188 
1189         union {
1190             /* Information about CB */
1191             struct {
1192                 /* Usage count of CB */
1193                 __u32 usage_cnt;
1194                 __u32 pad;
1195             };
1196 
1197             /* CB mapped address to device MMU */
1198             __u64 device_va;
1199         };
1200     };
1201 };
1202 
1203 union hl_cb_args {
1204     struct hl_cb_in in;
1205     struct hl_cb_out out;
1206 };
1207 
1208 /* HL_CS_CHUNK_FLAGS_ values
1209  *
1210  * HL_CS_CHUNK_FLAGS_USER_ALLOC_CB:
1211  *      Indicates if the CB was allocated and mapped by userspace
1212  *      (relevant to greco and above). User allocated CB is a command buffer,
1213  *      allocated by the user, via malloc (or similar). After allocating the
1214  *      CB, the user invokes - “memory ioctl” to map the user memory into a
1215  *      device virtual address. The user provides this address via the
1216  *      cb_handle field. The interface provides the ability to create a
1217  *      large CBs, Which aren’t limited to “HL_MAX_CB_SIZE”. Therefore, it
1218  *      increases the PCI-DMA queues throughput. This CB allocation method
1219  *      also reduces the use of Linux DMA-able memory pool. Which are limited
1220  *      and used by other Linux sub-systems.
1221  */
1222 #define HL_CS_CHUNK_FLAGS_USER_ALLOC_CB 0x1
1223 
1224 /*
1225  * This structure size must always be fixed to 64-bytes for backward
1226  * compatibility
1227  */
1228 struct hl_cs_chunk {
1229     union {
1230         /* Goya/Gaudi:
1231          * For external queue, this represents a Handle of CB on the
1232          * Host.
1233          * For internal queue in Goya, this represents an SRAM or
1234          * a DRAM address of the internal CB. In Gaudi, this might also
1235          * represent a mapped host address of the CB.
1236          *
1237          * Greco onwards:
1238          * For H/W queue, this represents either a Handle of CB on the
1239          * Host, or an SRAM, a DRAM, or a mapped host address of the CB.
1240          *
1241          * A mapped host address is in the device address space, after
1242          * a host address was mapped by the device MMU.
1243          */
1244         __u64 cb_handle;
1245 
1246         /* Relevant only when HL_CS_FLAGS_WAIT or
1247          * HL_CS_FLAGS_COLLECTIVE_WAIT is set
1248          * This holds address of array of u64 values that contain
1249          * signal CS sequence numbers. The wait described by
1250          * this job will listen on all those signals
1251          * (wait event per signal)
1252          */
1253         __u64 signal_seq_arr;
1254 
1255         /*
1256          * Relevant only when HL_CS_FLAGS_WAIT or
1257          * HL_CS_FLAGS_COLLECTIVE_WAIT is set
1258          * along with HL_CS_FLAGS_ENCAP_SIGNALS.
1259          * This is the CS sequence which has the encapsulated signals.
1260          */
1261         __u64 encaps_signal_seq;
1262     };
1263 
1264     /* Index of queue to put the CB on */
1265     __u32 queue_index;
1266 
1267     union {
1268         /*
1269          * Size of command buffer with valid packets
1270          * Can be smaller then actual CB size
1271          */
1272         __u32 cb_size;
1273 
1274         /* Relevant only when HL_CS_FLAGS_WAIT or
1275          * HL_CS_FLAGS_COLLECTIVE_WAIT is set.
1276          * Number of entries in signal_seq_arr
1277          */
1278         __u32 num_signal_seq_arr;
1279 
1280         /* Relevant only when HL_CS_FLAGS_WAIT or
1281          * HL_CS_FLAGS_COLLECTIVE_WAIT is set along
1282          * with HL_CS_FLAGS_ENCAP_SIGNALS
1283          * This set the signals range that the user want to wait for
1284          * out of the whole reserved signals range.
1285          * e.g if the signals range is 20, and user don't want
1286          * to wait for signal 8, so he set this offset to 7, then
1287          * he call the API again with 9 and so on till 20.
1288          */
1289         __u32 encaps_signal_offset;
1290     };
1291 
1292     /* HL_CS_CHUNK_FLAGS_* */
1293     __u32 cs_chunk_flags;
1294 
1295     /* Relevant only when HL_CS_FLAGS_COLLECTIVE_WAIT is set.
1296      * This holds the collective engine ID. The wait described by this job
1297      * will sync with this engine and with all NICs before completion.
1298      */
1299     __u32 collective_engine_id;
1300 
1301     /* Align structure to 64 bytes */
1302     __u32 pad[10];
1303 };
1304 
1305 /* SIGNAL/WAIT/COLLECTIVE_WAIT flags are mutually exclusive */
1306 #define HL_CS_FLAGS_FORCE_RESTORE       0x1
1307 #define HL_CS_FLAGS_SIGNAL          0x2
1308 #define HL_CS_FLAGS_WAIT            0x4
1309 #define HL_CS_FLAGS_COLLECTIVE_WAIT     0x8
1310 
1311 #define HL_CS_FLAGS_TIMESTAMP           0x20
1312 #define HL_CS_FLAGS_STAGED_SUBMISSION       0x40
1313 #define HL_CS_FLAGS_STAGED_SUBMISSION_FIRST 0x80
1314 #define HL_CS_FLAGS_STAGED_SUBMISSION_LAST  0x100
1315 #define HL_CS_FLAGS_CUSTOM_TIMEOUT      0x200
1316 #define HL_CS_FLAGS_SKIP_RESET_ON_TIMEOUT   0x400
1317 
1318 /*
1319  * The encapsulated signals CS is merged into the existing CS ioctls.
1320  * In order to use this feature need to follow the below procedure:
1321  * 1. Reserve signals, set the CS type to HL_CS_FLAGS_RESERVE_SIGNALS_ONLY
1322  *    the output of this API will be the SOB offset from CFG_BASE.
1323  *    this address will be used to patch CB cmds to do the signaling for this
1324  *    SOB by incrementing it's value.
1325  *    for reverting the reservation use HL_CS_FLAGS_UNRESERVE_SIGNALS_ONLY
1326  *    CS type, note that this might fail if out-of-sync happened to the SOB
1327  *    value, in case other signaling request to the same SOB occurred between
1328  *    reserve-unreserve calls.
1329  * 2. Use the staged CS to do the encapsulated signaling jobs.
1330  *    use HL_CS_FLAGS_STAGED_SUBMISSION and HL_CS_FLAGS_STAGED_SUBMISSION_FIRST
1331  *    along with HL_CS_FLAGS_ENCAP_SIGNALS flag, and set encaps_signal_offset
1332  *    field. This offset allows app to wait on part of the reserved signals.
1333  * 3. Use WAIT/COLLECTIVE WAIT CS along with HL_CS_FLAGS_ENCAP_SIGNALS flag
1334  *    to wait for the encapsulated signals.
1335  */
1336 #define HL_CS_FLAGS_ENCAP_SIGNALS       0x800
1337 #define HL_CS_FLAGS_RESERVE_SIGNALS_ONLY    0x1000
1338 #define HL_CS_FLAGS_UNRESERVE_SIGNALS_ONLY  0x2000
1339 
1340 #define HL_CS_STATUS_SUCCESS        0
1341 
1342 #define HL_MAX_JOBS_PER_CS      512
1343 
1344 struct hl_cs_in {
1345 
1346     /* this holds address of array of hl_cs_chunk for restore phase */
1347     __u64 chunks_restore;
1348 
1349     /* holds address of array of hl_cs_chunk for execution phase */
1350     __u64 chunks_execute;
1351 
1352     union {
1353         /*
1354          * Sequence number of a staged submission CS
1355          * valid only if HL_CS_FLAGS_STAGED_SUBMISSION is set and
1356          * HL_CS_FLAGS_STAGED_SUBMISSION_FIRST is unset.
1357          */
1358         __u64 seq;
1359 
1360         /*
1361          * Encapsulated signals handle id
1362          * Valid for two flows:
1363          * 1. CS with encapsulated signals:
1364          *    when HL_CS_FLAGS_STAGED_SUBMISSION and
1365          *    HL_CS_FLAGS_STAGED_SUBMISSION_FIRST
1366          *    and HL_CS_FLAGS_ENCAP_SIGNALS are set.
1367          * 2. unreserve signals:
1368          *    valid when HL_CS_FLAGS_UNRESERVE_SIGNALS_ONLY is set.
1369          */
1370         __u32 encaps_sig_handle_id;
1371 
1372         /* Valid only when HL_CS_FLAGS_RESERVE_SIGNALS_ONLY is set */
1373         struct {
1374             /* Encapsulated signals number */
1375             __u32 encaps_signals_count;
1376 
1377             /* Encapsulated signals queue index (stream) */
1378             __u32 encaps_signals_q_idx;
1379         };
1380     };
1381 
1382     /* Number of chunks in restore phase array. Maximum number is
1383      * HL_MAX_JOBS_PER_CS
1384      */
1385     __u32 num_chunks_restore;
1386 
1387     /* Number of chunks in execution array. Maximum number is
1388      * HL_MAX_JOBS_PER_CS
1389      */
1390     __u32 num_chunks_execute;
1391 
1392     /* timeout in seconds - valid only if HL_CS_FLAGS_CUSTOM_TIMEOUT
1393      * is set
1394      */
1395     __u32 timeout;
1396 
1397     /* HL_CS_FLAGS_* */
1398     __u32 cs_flags;
1399 
1400     /* Context ID - Currently not in use */
1401     __u32 ctx_id;
1402     __u8 pad[4];
1403 };
1404 
1405 struct hl_cs_out {
1406     union {
1407         /*
1408          * seq holds the sequence number of the CS to pass to wait
1409          * ioctl. All values are valid except for 0 and ULLONG_MAX
1410          */
1411         __u64 seq;
1412 
1413         /* Valid only when HL_CS_FLAGS_RESERVE_SIGNALS_ONLY is set */
1414         struct {
1415             /* This is the resereved signal handle id */
1416             __u32 handle_id;
1417 
1418             /* This is the signals count */
1419             __u32 count;
1420         };
1421     };
1422 
1423     /* HL_CS_STATUS */
1424     __u32 status;
1425 
1426     /*
1427      * SOB base address offset
1428      * Valid only when HL_CS_FLAGS_RESERVE_SIGNALS_ONLY or HL_CS_FLAGS_SIGNAL is set
1429      */
1430     __u32 sob_base_addr_offset;
1431 
1432     /*
1433      * Count of completed signals in SOB before current signal submission.
1434      * Valid only when (HL_CS_FLAGS_ENCAP_SIGNALS & HL_CS_FLAGS_STAGED_SUBMISSION)
1435      * or HL_CS_FLAGS_SIGNAL is set
1436      */
1437     __u16 sob_count_before_submission;
1438     __u16 pad[3];
1439 };
1440 
1441 union hl_cs_args {
1442     struct hl_cs_in in;
1443     struct hl_cs_out out;
1444 };
1445 
1446 #define HL_WAIT_CS_FLAGS_INTERRUPT      0x2
1447 #define HL_WAIT_CS_FLAGS_INTERRUPT_MASK     0xFFF00000
1448 #define HL_WAIT_CS_FLAGS_ANY_CQ_INTERRUPT   0xFFF00000
1449 #define HL_WAIT_CS_FLAGS_ANY_DEC_INTERRUPT  0xFFE00000
1450 #define HL_WAIT_CS_FLAGS_MULTI_CS       0x4
1451 #define HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ    0x10
1452 #define HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT 0x20
1453 
1454 #define HL_WAIT_MULTI_CS_LIST_MAX_LEN   32
1455 
1456 struct hl_wait_cs_in {
1457     union {
1458         struct {
1459             /*
1460              * In case of wait_cs holds the CS sequence number.
1461              * In case of wait for multi CS hold a user pointer to
1462              * an array of CS sequence numbers
1463              */
1464             __u64 seq;
1465             /* Absolute timeout to wait for command submission
1466              * in microseconds
1467              */
1468             __u64 timeout_us;
1469         };
1470 
1471         struct {
1472             union {
1473                 /* User address for completion comparison.
1474                  * upon interrupt, driver will compare the value pointed
1475                  * by this address with the supplied target value.
1476                  * in order not to perform any comparison, set address
1477                  * to all 1s.
1478                  * Relevant only when HL_WAIT_CS_FLAGS_INTERRUPT is set
1479                  */
1480                 __u64 addr;
1481 
1482                 /* cq_counters_handle to a kernel mapped cb which contains
1483                  * cq counters.
1484                  * Relevant only when HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ is set
1485                  */
1486                 __u64 cq_counters_handle;
1487             };
1488 
1489             /* Target value for completion comparison */
1490             __u64 target;
1491         };
1492     };
1493 
1494     /* Context ID - Currently not in use */
1495     __u32 ctx_id;
1496 
1497     /* HL_WAIT_CS_FLAGS_*
1498      * If HL_WAIT_CS_FLAGS_INTERRUPT is set, this field should include
1499      * interrupt id according to HL_WAIT_CS_FLAGS_INTERRUPT_MASK
1500      *
1501      * in order to wait for any CQ interrupt, set interrupt value to
1502      * HL_WAIT_CS_FLAGS_ANY_CQ_INTERRUPT.
1503      *
1504      * in order to wait for any decoder interrupt, set interrupt value to
1505      * HL_WAIT_CS_FLAGS_ANY_DEC_INTERRUPT.
1506      */
1507     __u32 flags;
1508 
1509     union {
1510         struct {
1511             /* Multi CS API info- valid entries in multi-CS array */
1512             __u8 seq_arr_len;
1513             __u8 pad[7];
1514         };
1515 
1516         /* Absolute timeout to wait for an interrupt in microseconds.
1517          * Relevant only when HL_WAIT_CS_FLAGS_INTERRUPT is set
1518          */
1519         __u64 interrupt_timeout_us;
1520     };
1521 
1522     /*
1523      * cq counter offset inside the counters cb pointed by cq_counters_handle above.
1524      * upon interrupt, driver will compare the value pointed
1525      * by this address (cq_counters_handle + cq_counters_offset)
1526      * with the supplied target value.
1527      * relevant only when HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ is set
1528      */
1529     __u64 cq_counters_offset;
1530 
1531     /*
1532      * Timestamp_handle timestamps buffer handle.
1533      * relevant only when HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT is set
1534      */
1535     __u64 timestamp_handle;
1536 
1537     /*
1538      * Timestamp_offset is offset inside the timestamp buffer pointed by timestamp_handle above.
1539      * upon interrupt, if the cq reached the target value then driver will write
1540      * timestamp to this offset.
1541      * relevant only when HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT is set
1542      */
1543     __u64 timestamp_offset;
1544 };
1545 
1546 #define HL_WAIT_CS_STATUS_COMPLETED 0
1547 #define HL_WAIT_CS_STATUS_BUSY      1
1548 #define HL_WAIT_CS_STATUS_TIMEDOUT  2
1549 #define HL_WAIT_CS_STATUS_ABORTED   3
1550 
1551 #define HL_WAIT_CS_STATUS_FLAG_GONE     0x1
1552 #define HL_WAIT_CS_STATUS_FLAG_TIMESTAMP_VLD    0x2
1553 
1554 struct hl_wait_cs_out {
1555     /* HL_WAIT_CS_STATUS_* */
1556     __u32 status;
1557     /* HL_WAIT_CS_STATUS_FLAG* */
1558     __u32 flags;
1559     /*
1560      * valid only if HL_WAIT_CS_STATUS_FLAG_TIMESTAMP_VLD is set
1561      * for wait_cs: timestamp of CS completion
1562      * for wait_multi_cs: timestamp of FIRST CS completion
1563      */
1564     __s64 timestamp_nsec;
1565     /* multi CS completion bitmap */
1566     __u32 cs_completion_map;
1567     __u32 pad;
1568 };
1569 
1570 union hl_wait_cs_args {
1571     struct hl_wait_cs_in in;
1572     struct hl_wait_cs_out out;
1573 };
1574 
1575 /* Opcode to allocate device memory */
1576 #define HL_MEM_OP_ALLOC         0
1577 
1578 /* Opcode to free previously allocated device memory */
1579 #define HL_MEM_OP_FREE          1
1580 
1581 /* Opcode to map host and device memory */
1582 #define HL_MEM_OP_MAP           2
1583 
1584 /* Opcode to unmap previously mapped host and device memory */
1585 #define HL_MEM_OP_UNMAP         3
1586 
1587 /* Opcode to map a hw block */
1588 #define HL_MEM_OP_MAP_BLOCK     4
1589 
1590 /* Opcode to create DMA-BUF object for an existing device memory allocation
1591  * and to export an FD of that DMA-BUF back to the caller
1592  */
1593 #define HL_MEM_OP_EXPORT_DMABUF_FD  5
1594 
1595 /* Opcode to create timestamps pool for user interrupts registration support
1596  * The memory will be allocated by the kernel driver, A timestamp buffer which the user
1597  * will get handle to it for mmap, and another internal buffer used by the
1598  * driver for registration management
1599  * The memory will be freed when the user closes the file descriptor(ctx close)
1600  */
1601 #define HL_MEM_OP_TS_ALLOC      6
1602 
1603 /* Memory flags */
1604 #define HL_MEM_CONTIGUOUS   0x1
1605 #define HL_MEM_SHARED       0x2
1606 #define HL_MEM_USERPTR      0x4
1607 #define HL_MEM_FORCE_HINT   0x8
1608 #define HL_MEM_PREFETCH     0x40
1609 
1610 /**
1611  * structure hl_mem_in - structure that handle input args for memory IOCTL
1612  * @union arg: union of structures to be used based on the input operation
1613  * @op: specify the requested memory operation (one of the HL_MEM_OP_* definitions).
1614  * @flags: flags for the memory operation (one of the HL_MEM_* definitions).
1615  *         For the HL_MEM_OP_EXPORT_DMABUF_FD opcode, this field holds the DMA-BUF file/FD flags.
1616  * @ctx_id: context ID - currently not in use.
1617  * @num_of_elements: number of timestamp elements used only with HL_MEM_OP_TS_ALLOC opcode.
1618  */
1619 struct hl_mem_in {
1620     union {
1621         /**
1622          * structure for device memory allocation (used with the HL_MEM_OP_ALLOC op)
1623          * @mem_size: memory size to allocate
1624          * @page_size: page size to use on allocation. when the value is 0 the default page
1625          *             size will be taken.
1626          */
1627         struct {
1628             __u64 mem_size;
1629             __u64 page_size;
1630         } alloc;
1631 
1632         /**
1633          * structure for free-ing device memory (used with the HL_MEM_OP_FREE op)
1634          * @handle: handle returned from HL_MEM_OP_ALLOC
1635          */
1636         struct {
1637             __u64 handle;
1638         } free;
1639 
1640         /**
1641          * structure for mapping device memory (used with the HL_MEM_OP_MAP op)
1642          * @hint_addr: requested virtual address of mapped memory.
1643          *             the driver will try to map the requested region to this hint
1644          *             address, as long as the address is valid and not already mapped.
1645          *             the user should check the returned address of the IOCTL to make
1646          *             sure he got the hint address.
1647          *             passing 0 here means that the driver will choose the address itself.
1648          * @handle: handle returned from HL_MEM_OP_ALLOC.
1649          */
1650         struct {
1651             __u64 hint_addr;
1652             __u64 handle;
1653         } map_device;
1654 
1655         /**
1656          * structure for mapping host memory (used with the HL_MEM_OP_MAP op)
1657          * @host_virt_addr: address of allocated host memory.
1658          * @hint_addr: requested virtual address of mapped memory.
1659          *             the driver will try to map the requested region to this hint
1660          *             address, as long as the address is valid and not already mapped.
1661          *             the user should check the returned address of the IOCTL to make
1662          *             sure he got the hint address.
1663          *             passing 0 here means that the driver will choose the address itself.
1664          * @size: size of allocated host memory.
1665          */
1666         struct {
1667             __u64 host_virt_addr;
1668             __u64 hint_addr;
1669             __u64 mem_size;
1670         } map_host;
1671 
1672         /**
1673          * structure for mapping hw block (used with the HL_MEM_OP_MAP_BLOCK op)
1674          * @block_addr:HW block address to map, a handle and size will be returned
1675          *             to the user and will be used to mmap the relevant block.
1676          *             only addresses from configuration space are allowed.
1677          */
1678         struct {
1679             __u64 block_addr;
1680         } map_block;
1681 
1682         /**
1683          * structure for unmapping host memory (used with the HL_MEM_OP_UNMAP op)
1684          * @device_virt_addr: virtual address returned from HL_MEM_OP_MAP
1685          */
1686         struct {
1687             __u64 device_virt_addr;
1688         } unmap;
1689 
1690         /**
1691          * structure for exporting DMABUF object (used with
1692          * the HL_MEM_OP_EXPORT_DMABUF_FD op)
1693          * @handle: handle returned from HL_MEM_OP_ALLOC.
1694          *          in Gaudi, where we don't have MMU for the device memory, the
1695          *          driver expects a physical address (instead of a handle) in the
1696          *          device memory space.
1697          * @mem_size: size of memory allocation. Relevant only for GAUDI
1698          */
1699         struct {
1700             __u64 handle;
1701             __u64 mem_size;
1702         } export_dmabuf_fd;
1703     };
1704 
1705     __u32 op;
1706     __u32 flags;
1707     __u32 ctx_id;
1708     __u32 num_of_elements;
1709 };
1710 
1711 struct hl_mem_out {
1712     union {
1713         /*
1714          * Used for HL_MEM_OP_MAP as the virtual address that was
1715          * assigned in the device VA space.
1716          * A value of 0 means the requested operation failed.
1717          */
1718         __u64 device_virt_addr;
1719 
1720         /*
1721          * Used in HL_MEM_OP_ALLOC
1722          * This is the assigned handle for the allocated memory
1723          */
1724         __u64 handle;
1725 
1726         struct {
1727             /*
1728              * Used in HL_MEM_OP_MAP_BLOCK.
1729              * This is the assigned handle for the mapped block
1730              */
1731             __u64 block_handle;
1732 
1733             /*
1734              * Used in HL_MEM_OP_MAP_BLOCK
1735              * This is the size of the mapped block
1736              */
1737             __u32 block_size;
1738 
1739             __u32 pad;
1740         };
1741 
1742         /* Returned in HL_MEM_OP_EXPORT_DMABUF_FD. Represents the
1743          * DMA-BUF object that was created to describe a memory
1744          * allocation on the device's memory space. The FD should be
1745          * passed to the importer driver
1746          */
1747         __s32 fd;
1748     };
1749 };
1750 
1751 union hl_mem_args {
1752     struct hl_mem_in in;
1753     struct hl_mem_out out;
1754 };
1755 
1756 #define HL_DEBUG_MAX_AUX_VALUES     10
1757 
1758 struct hl_debug_params_etr {
1759     /* Address in memory to allocate buffer */
1760     __u64 buffer_address;
1761 
1762     /* Size of buffer to allocate */
1763     __u64 buffer_size;
1764 
1765     /* Sink operation mode: SW fifo, HW fifo, Circular buffer */
1766     __u32 sink_mode;
1767     __u32 pad;
1768 };
1769 
1770 struct hl_debug_params_etf {
1771     /* Address in memory to allocate buffer */
1772     __u64 buffer_address;
1773 
1774     /* Size of buffer to allocate */
1775     __u64 buffer_size;
1776 
1777     /* Sink operation mode: SW fifo, HW fifo, Circular buffer */
1778     __u32 sink_mode;
1779     __u32 pad;
1780 };
1781 
1782 struct hl_debug_params_stm {
1783     /* Two bit masks for HW event and Stimulus Port */
1784     __u64 he_mask;
1785     __u64 sp_mask;
1786 
1787     /* Trace source ID */
1788     __u32 id;
1789 
1790     /* Frequency for the timestamp register */
1791     __u32 frequency;
1792 };
1793 
1794 struct hl_debug_params_bmon {
1795     /* Two address ranges that the user can request to filter */
1796     __u64 start_addr0;
1797     __u64 addr_mask0;
1798 
1799     __u64 start_addr1;
1800     __u64 addr_mask1;
1801 
1802     /* Capture window configuration */
1803     __u32 bw_win;
1804     __u32 win_capture;
1805 
1806     /* Trace source ID */
1807     __u32 id;
1808 
1809     /* Control register */
1810     __u32 control;
1811 
1812     /* Two more address ranges that the user can request to filter */
1813     __u64 start_addr2;
1814     __u64 end_addr2;
1815 
1816     __u64 start_addr3;
1817     __u64 end_addr3;
1818 };
1819 
1820 struct hl_debug_params_spmu {
1821     /* Event types selection */
1822     __u64 event_types[HL_DEBUG_MAX_AUX_VALUES];
1823 
1824     /* Number of event types selection */
1825     __u32 event_types_num;
1826 
1827     /* TRC configuration register values */
1828     __u32 pmtrc_val;
1829     __u32 trc_ctrl_host_val;
1830     __u32 trc_en_host_val;
1831 };
1832 
1833 /* Opcode for ETR component */
1834 #define HL_DEBUG_OP_ETR     0
1835 /* Opcode for ETF component */
1836 #define HL_DEBUG_OP_ETF     1
1837 /* Opcode for STM component */
1838 #define HL_DEBUG_OP_STM     2
1839 /* Opcode for FUNNEL component */
1840 #define HL_DEBUG_OP_FUNNEL  3
1841 /* Opcode for BMON component */
1842 #define HL_DEBUG_OP_BMON    4
1843 /* Opcode for SPMU component */
1844 #define HL_DEBUG_OP_SPMU    5
1845 /* Opcode for timestamp (deprecated) */
1846 #define HL_DEBUG_OP_TIMESTAMP   6
1847 /* Opcode for setting the device into or out of debug mode. The enable
1848  * variable should be 1 for enabling debug mode and 0 for disabling it
1849  */
1850 #define HL_DEBUG_OP_SET_MODE    7
1851 
1852 struct hl_debug_args {
1853     /*
1854      * Pointer to user input structure.
1855      * This field is relevant to specific opcodes.
1856      */
1857     __u64 input_ptr;
1858     /* Pointer to user output structure */
1859     __u64 output_ptr;
1860     /* Size of user input structure */
1861     __u32 input_size;
1862     /* Size of user output structure */
1863     __u32 output_size;
1864     /* HL_DEBUG_OP_* */
1865     __u32 op;
1866     /*
1867      * Register index in the component, taken from the debug_regs_index enum
1868      * in the various ASIC header files
1869      */
1870     __u32 reg_idx;
1871     /* Enable/disable */
1872     __u32 enable;
1873     /* Context ID - Currently not in use */
1874     __u32 ctx_id;
1875 };
1876 
1877 /*
1878  * Notifier event values - for the notification mechanism and the HL_INFO_GET_EVENTS command
1879  *
1880  * HL_NOTIFIER_EVENT_TPC_ASSERT     - Indicates TPC assert event
1881  * HL_NOTIFIER_EVENT_UNDEFINED_OPCODE   - Indicates undefined operation code
1882  * HL_NOTIFIER_EVENT_DEVICE_RESET   - Indicates device requires a reset
1883  * HL_NOTIFIER_EVENT_CS_TIMEOUT     - Indicates CS timeout error
1884  * HL_NOTIFIER_EVENT_DEVICE_UNAVAILABLE - Indicates device is unavailable
1885  */
1886 #define HL_NOTIFIER_EVENT_TPC_ASSERT        (1ULL << 0)
1887 #define HL_NOTIFIER_EVENT_UNDEFINED_OPCODE  (1ULL << 1)
1888 #define HL_NOTIFIER_EVENT_DEVICE_RESET      (1ULL << 2)
1889 #define HL_NOTIFIER_EVENT_CS_TIMEOUT        (1ULL << 3)
1890 #define HL_NOTIFIER_EVENT_DEVICE_UNAVAILABLE    (1ULL << 4)
1891 
1892 /*
1893  * Various information operations such as:
1894  * - H/W IP information
1895  * - Current dram usage
1896  *
1897  * The user calls this IOCTL with an opcode that describes the required
1898  * information. The user should supply a pointer to a user-allocated memory
1899  * chunk, which will be filled by the driver with the requested information.
1900  *
1901  * The user supplies the maximum amount of size to copy into the user's memory,
1902  * in order to prevent data corruption in case of differences between the
1903  * definitions of structures in kernel and userspace, e.g. in case of old
1904  * userspace and new kernel driver
1905  */
1906 #define HL_IOCTL_INFO   \
1907         _IOWR('H', 0x01, struct hl_info_args)
1908 
1909 /*
1910  * Command Buffer
1911  * - Request a Command Buffer
1912  * - Destroy a Command Buffer
1913  *
1914  * The command buffers are memory blocks that reside in DMA-able address
1915  * space and are physically contiguous so they can be accessed by the device
1916  * directly. They are allocated using the coherent DMA API.
1917  *
1918  * When creating a new CB, the IOCTL returns a handle of it, and the user-space
1919  * process needs to use that handle to mmap the buffer so it can access them.
1920  *
1921  * In some instances, the device must access the command buffer through the
1922  * device's MMU, and thus its memory should be mapped. In these cases, user can
1923  * indicate the driver that such a mapping is required.
1924  * The resulting device virtual address will be used internally by the driver,
1925  * and won't be returned to user.
1926  *
1927  */
1928 #define HL_IOCTL_CB     \
1929         _IOWR('H', 0x02, union hl_cb_args)
1930 
1931 /*
1932  * Command Submission
1933  *
1934  * To submit work to the device, the user need to call this IOCTL with a set
1935  * of JOBS. That set of JOBS constitutes a CS object.
1936  * Each JOB will be enqueued on a specific queue, according to the user's input.
1937  * There can be more then one JOB per queue.
1938  *
1939  * The CS IOCTL will receive two sets of JOBS. One set is for "restore" phase
1940  * and a second set is for "execution" phase.
1941  * The JOBS on the "restore" phase are enqueued only after context-switch
1942  * (or if its the first CS for this context). The user can also order the
1943  * driver to run the "restore" phase explicitly
1944  *
1945  * Goya/Gaudi:
1946  * There are two types of queues - external and internal. External queues
1947  * are DMA queues which transfer data from/to the Host. All other queues are
1948  * internal. The driver will get completion notifications from the device only
1949  * on JOBS which are enqueued in the external queues.
1950  *
1951  * Greco onwards:
1952  * There is a single type of queue for all types of engines, either DMA engines
1953  * for transfers from/to the host or inside the device, or compute engines.
1954  * The driver will get completion notifications from the device for all queues.
1955  *
1956  * For jobs on external queues, the user needs to create command buffers
1957  * through the CB ioctl and give the CB's handle to the CS ioctl. For jobs on
1958  * internal queues, the user needs to prepare a "command buffer" with packets
1959  * on either the device SRAM/DRAM or the host, and give the device address of
1960  * that buffer to the CS ioctl.
1961  * For jobs on H/W queues both options of command buffers are valid.
1962  *
1963  * This IOCTL is asynchronous in regard to the actual execution of the CS. This
1964  * means it returns immediately after ALL the JOBS were enqueued on their
1965  * relevant queues. Therefore, the user mustn't assume the CS has been completed
1966  * or has even started to execute.
1967  *
1968  * Upon successful enqueue, the IOCTL returns a sequence number which the user
1969  * can use with the "Wait for CS" IOCTL to check whether the handle's CS
1970  * non-internal JOBS have been completed. Note that if the CS has internal JOBS
1971  * which can execute AFTER the external JOBS have finished, the driver might
1972  * report that the CS has finished executing BEFORE the internal JOBS have
1973  * actually finished executing.
1974  *
1975  * Even though the sequence number increments per CS, the user can NOT
1976  * automatically assume that if CS with sequence number N finished, then CS
1977  * with sequence number N-1 also finished. The user can make this assumption if
1978  * and only if CS N and CS N-1 are exactly the same (same CBs for the same
1979  * queues).
1980  */
1981 #define HL_IOCTL_CS         \
1982         _IOWR('H', 0x03, union hl_cs_args)
1983 
1984 /*
1985  * Wait for Command Submission
1986  *
1987  * The user can call this IOCTL with a handle it received from the CS IOCTL
1988  * to wait until the handle's CS has finished executing. The user will wait
1989  * inside the kernel until the CS has finished or until the user-requested
1990  * timeout has expired.
1991  *
1992  * If the timeout value is 0, the driver won't sleep at all. It will check
1993  * the status of the CS and return immediately
1994  *
1995  * The return value of the IOCTL is a standard Linux error code. The possible
1996  * values are:
1997  *
1998  * EINTR     - Kernel waiting has been interrupted, e.g. due to OS signal
1999  *             that the user process received
2000  * ETIMEDOUT - The CS has caused a timeout on the device
2001  * EIO       - The CS was aborted (usually because the device was reset)
2002  * ENODEV    - The device wants to do hard-reset (so user need to close FD)
2003  *
2004  * The driver also returns a custom define in case the IOCTL call returned 0.
2005  * The define can be one of the following:
2006  *
2007  * HL_WAIT_CS_STATUS_COMPLETED   - The CS has been completed successfully (0)
2008  * HL_WAIT_CS_STATUS_BUSY        - The CS is still executing (0)
2009  * HL_WAIT_CS_STATUS_TIMEDOUT    - The CS has caused a timeout on the device
2010  *                                 (ETIMEDOUT)
2011  * HL_WAIT_CS_STATUS_ABORTED     - The CS was aborted, usually because the
2012  *                                 device was reset (EIO)
2013  */
2014 
2015 #define HL_IOCTL_WAIT_CS            \
2016         _IOWR('H', 0x04, union hl_wait_cs_args)
2017 
2018 /*
2019  * Memory
2020  * - Map host memory to device MMU
2021  * - Unmap host memory from device MMU
2022  *
2023  * This IOCTL allows the user to map host memory to the device MMU
2024  *
2025  * For host memory, the IOCTL doesn't allocate memory. The user is supposed
2026  * to allocate the memory in user-space (malloc/new). The driver pins the
2027  * physical pages (up to the allowed limit by the OS), assigns a virtual
2028  * address in the device VA space and initializes the device MMU.
2029  *
2030  * There is an option for the user to specify the requested virtual address.
2031  *
2032  */
2033 #define HL_IOCTL_MEMORY     \
2034         _IOWR('H', 0x05, union hl_mem_args)
2035 
2036 /*
2037  * Debug
2038  * - Enable/disable the ETR/ETF/FUNNEL/STM/BMON/SPMU debug traces
2039  *
2040  * This IOCTL allows the user to get debug traces from the chip.
2041  *
2042  * Before the user can send configuration requests of the various
2043  * debug/profile engines, it needs to set the device into debug mode.
2044  * This is because the debug/profile infrastructure is shared component in the
2045  * device and we can't allow multiple users to access it at the same time.
2046  *
2047  * Once a user set the device into debug mode, the driver won't allow other
2048  * users to "work" with the device, i.e. open a FD. If there are multiple users
2049  * opened on the device, the driver won't allow any user to debug the device.
2050  *
2051  * For each configuration request, the user needs to provide the register index
2052  * and essential data such as buffer address and size.
2053  *
2054  * Once the user has finished using the debug/profile engines, he should
2055  * set the device into non-debug mode, i.e. disable debug mode.
2056  *
2057  * The driver can decide to "kick out" the user if he abuses this interface.
2058  *
2059  */
2060 #define HL_IOCTL_DEBUG      \
2061         _IOWR('H', 0x06, struct hl_debug_args)
2062 
2063 #define HL_COMMAND_START    0x01
2064 #define HL_COMMAND_END      0x07
2065 
2066 #endif /* HABANALABS_H_ */