1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2013-2020 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 #pragma once
25 
26 #include <nvtypes.h>
27 
28 //
29 // This file was generated with FINN, an NVIDIA coding tool.
30 // Source file:      ctrl/ctrl2080/ctrl2080gpumon.finn
31 //
32 
33 
34 
35 #include "ctrl/ctrl2080/ctrl2080base.h"
36 
37 /*!
38  *  This structure represents base class of GPU monitoring sample.
39  */
40 typedef struct NV2080_CTRL_GPUMON_SAMPLE {
41     /*!
42     * Timestamps in nano-seconds.
43     */
44     NV_DECLARE_ALIGNED(NvU64 timeStamp, 8);
45 } NV2080_CTRL_GPUMON_SAMPLE;
46 
47 /*!
48  *  This structure represents base GPU monitoring sample.
49  */
50 typedef struct NV2080_CTRL_GPUMON_SAMPLES {
51     /*!
52     * Type of the sample, see NV2080_CTRL_GPUMON_SAMPLE_TYPE_* for reference.
53     */
54     NvU8  type;
55     /*!
56     * Size of the buffer, this should be
57     * bufSize ==  NV2080_CTRL_*_GPUMON_SAMPLE_COUNT_*
58     *    sizeof(derived type of NV2080_CTRL_GPUMON_SAMPLE).
59     */
60     NvU32 bufSize;
61     /*!
62     * Number of samples in ring buffer.
63     */
64     NvU32 count;
65     /*!
66     * tracks the offset of the tail in the circular queue array pSamples.
67     */
68     NvU32 tracker;
69     /*!
70     * Pointer to a circular queue based on array of NV2080_CTRL_GPUMON_SAMPLE
71     * or its derived types structs with size == bufSize.
72     *
73     * @note This circular queue wraps around after 10 seconds of sampling,
74     * and it is clients' responsibility to query within this time frame in
75     * order to avoid losing samples.
76     * @note With one exception, this queue contains last 10 seconds of samples
77     * with tracker poiniting to oldest entry and entry before tracker as the
78     * newest entry. Exception is when queue is not full (i.e. tracker is
79     * pointing to a zeroed out entry), in that case valid entries are between 0
80     * and tracker.
81     * @note Clients can store tracker from previous query in order to provide
82     * samples since last read.
83     */
84     NV_DECLARE_ALIGNED(NvP64 pSamples, 8);
85 } NV2080_CTRL_GPUMON_SAMPLES;
86 
87 /*!
88  * Enumeration of GPU monitoring sample types.
89  */
90 #define NV2080_CTRL_GPUMON_SAMPLE_TYPE_PWR_MONITOR_STATUS 0x00000001
91 #define NV2080_CTRL_GPUMON_SAMPLE_TYPE_PERFMON_UTIL       0x00000002
92 
93 /*!
94  * Macro for invalid PID.
95  */
96 #define NV2080_GPUMON_PID_INVALID         ((NvU32)(~0))
97