-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathzes.py
4335 lines (3778 loc) · 288 KB
/
zes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
Copyright (C) 2019-2021 Intel Corporation
SPDX-License-Identifier: MIT
@file zes.py
@version v1.12-r1.12.15
"""
import platform
from ctypes import *
from enum import *
###############################################################################
__version__ = "1.0"
###############################################################################
## @brief Handle to a driver instance
class zes_driver_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle of device object
class zes_device_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle for a Sysman device scheduler queue
class zes_sched_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle for a Sysman device performance factors
class zes_perf_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle for a Sysman device power domain
class zes_pwr_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle for a Sysman device frequency domain
class zes_freq_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle for a Sysman device engine group
class zes_engine_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle for a Sysman device standby control
class zes_standby_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle for a Sysman device firmware
class zes_firmware_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle for a Sysman device memory module
class zes_mem_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle for a Sysman fabric port
class zes_fabric_port_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle for a Sysman device temperature sensor
class zes_temp_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle for a Sysman device power supply
class zes_psu_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle for a Sysman device fan
class zes_fan_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle for a Sysman device LED
class zes_led_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle for a Sysman device RAS error set
class zes_ras_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle for a Sysman device diagnostics test suite
class zes_diag_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle for a Sysman device overclock domain
class zes_overclock_handle_t(c_void_p):
pass
###############################################################################
## @brief Handle for a Sysman virtual function management domain
class zes_vf_handle_t(c_void_p):
pass
###############################################################################
## @brief Defines structure types
class zes_structure_type_v(IntEnum):
DEVICE_PROPERTIES = 0x1 ## ::zes_device_properties_t
PCI_PROPERTIES = 0x2 ## ::zes_pci_properties_t
PCI_BAR_PROPERTIES = 0x3 ## ::zes_pci_bar_properties_t
DIAG_PROPERTIES = 0x4 ## ::zes_diag_properties_t
ENGINE_PROPERTIES = 0x5 ## ::zes_engine_properties_t
FABRIC_PORT_PROPERTIES = 0x6 ## ::zes_fabric_port_properties_t
FAN_PROPERTIES = 0x7 ## ::zes_fan_properties_t
FIRMWARE_PROPERTIES = 0x8 ## ::zes_firmware_properties_t
FREQ_PROPERTIES = 0x9 ## ::zes_freq_properties_t
LED_PROPERTIES = 0xa ## ::zes_led_properties_t
MEM_PROPERTIES = 0xb ## ::zes_mem_properties_t
PERF_PROPERTIES = 0xc ## ::zes_perf_properties_t
POWER_PROPERTIES = 0xd ## ::zes_power_properties_t
PSU_PROPERTIES = 0xe ## ::zes_psu_properties_t
RAS_PROPERTIES = 0xf ## ::zes_ras_properties_t
SCHED_PROPERTIES = 0x10 ## ::zes_sched_properties_t
SCHED_TIMEOUT_PROPERTIES = 0x11 ## ::zes_sched_timeout_properties_t
SCHED_TIMESLICE_PROPERTIES = 0x12 ## ::zes_sched_timeslice_properties_t
STANDBY_PROPERTIES = 0x13 ## ::zes_standby_properties_t
TEMP_PROPERTIES = 0x14 ## ::zes_temp_properties_t
DEVICE_STATE = 0x15 ## ::zes_device_state_t
PROCESS_STATE = 0x16 ## ::zes_process_state_t
PCI_STATE = 0x17 ## ::zes_pci_state_t
FABRIC_PORT_CONFIG = 0x18 ## ::zes_fabric_port_config_t
FABRIC_PORT_STATE = 0x19 ## ::zes_fabric_port_state_t
FAN_CONFIG = 0x1a ## ::zes_fan_config_t
FREQ_STATE = 0x1b ## ::zes_freq_state_t
OC_CAPABILITIES = 0x1c ## ::zes_oc_capabilities_t
LED_STATE = 0x1d ## ::zes_led_state_t
MEM_STATE = 0x1e ## ::zes_mem_state_t
PSU_STATE = 0x1f ## ::zes_psu_state_t
BASE_STATE = 0x20 ## ::zes_base_state_t
RAS_CONFIG = 0x21 ## ::zes_ras_config_t
RAS_STATE = 0x22 ## ::zes_ras_state_t
TEMP_CONFIG = 0x23 ## ::zes_temp_config_t
PCI_BAR_PROPERTIES_1_2 = 0x24 ## ::zes_pci_bar_properties_1_2_t
DEVICE_ECC_DESC = 0x25 ## ::zes_device_ecc_desc_t
DEVICE_ECC_PROPERTIES = 0x26 ## ::zes_device_ecc_properties_t
POWER_LIMIT_EXT_DESC = 0x27 ## ::zes_power_limit_ext_desc_t
POWER_EXT_PROPERTIES = 0x28 ## ::zes_power_ext_properties_t
OVERCLOCK_PROPERTIES = 0x29 ## ::zes_overclock_properties_t
FABRIC_PORT_ERROR_COUNTERS = 0x2a ## ::zes_fabric_port_error_counters_t
ENGINE_EXT_PROPERTIES = 0x2b ## ::zes_engine_ext_properties_t
RESET_PROPERTIES = 0x2c ## ::zes_reset_properties_t
DEVICE_EXT_PROPERTIES = 0x2d ## ::zes_device_ext_properties_t
DEVICE_UUID = 0x2e ## ::zes_uuid_t
POWER_DOMAIN_EXP_PROPERTIES = 0x00020001 ## ::zes_power_domain_exp_properties_t
MEM_BANDWIDTH_COUNTER_BITS_EXP_PROPERTIES = 0x00020002 ## ::zes_mem_bandwidth_counter_bits_exp_properties_t
MEMORY_PAGE_OFFLINE_STATE_EXP = 0x00020003 ## ::zes_mem_page_offline_state_exp_t
SUBDEVICE_EXP_PROPERTIES = 0x00020004 ## ::zes_subdevice_exp_properties_t
VF_EXP_PROPERTIES = 0x00020005 ## ::zes_vf_exp_properties_t
VF_UTIL_MEM_EXP = 0x00020006 ## ::zes_vf_util_mem_exp_t
VF_UTIL_ENGINE_EXP = 0x00020007 ## ::zes_vf_util_engine_exp_t
VF_EXP_CAPABILITIES = 0x00020008 ## ::zes_vf_exp_capabilities_t
VF_UTIL_MEM_EXP2 = 0x00020009 ## ::zes_vf_util_mem_exp2_t
VF_UTIL_ENGINE_EXP2 = 0x00020010 ## ::zes_vf_util_engine_exp2_t
VF_EXP2_CAPABILITIES = 0x00020011 ## ::zes_vf_exp2_capabilities_t
class zes_structure_type_t(c_int):
def __str__(self):
return str(zes_structure_type_v(self.value))
###############################################################################
## @brief Base for all properties types
class zes_base_properties_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p) ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
]
###############################################################################
## @brief Base for all descriptor types
class zes_base_desc_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p) ## [in][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
]
###############################################################################
## @brief Base for all state types
class zes_base_state_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p) ## [in][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
]
###############################################################################
## @brief Base for all config types
class zes_base_config_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p) ## [in][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
]
###############################################################################
## @brief Base for all capability types
class zes_base_capability_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p) ## [in][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
]
###############################################################################
## @brief Supported sysman initialization flags
class zes_init_flags_v(IntEnum):
PLACEHOLDER = ZE_BIT(0) ## placeholder for future use
class zes_init_flags_t(c_int):
def __str__(self):
return hex(self.value)
###############################################################################
## @brief Maximum extension name string size
ZES_MAX_EXTENSION_NAME = 256
###############################################################################
## @brief Extension properties queried using ::zesDriverGetExtensionProperties
class zes_driver_extension_properties_t(Structure):
_fields_ = [
("name", c_char * ZES_MAX_EXTENSION_NAME), ## [out] extension name
("version", c_ulong) ## [out] extension version using ::ZE_MAKE_VERSION
]
###############################################################################
## @brief Maximum number of characters in string properties.
ZES_STRING_PROPERTY_SIZE = 64
###############################################################################
## @brief Maximum device universal unique id (UUID) size in bytes.
ZES_MAX_UUID_SIZE = 16
###############################################################################
## @brief Types of accelerator engines
class zes_engine_type_flags_v(IntEnum):
OTHER = ZE_BIT(0) ## Undefined types of accelerators.
COMPUTE = ZE_BIT(1) ## Engines that process compute kernels only (no 3D content).
_3D = ZE_BIT(2) ## Engines that process 3D content only (no compute kernels).
MEDIA = ZE_BIT(3) ## Engines that process media workloads.
DMA = ZE_BIT(4) ## Engines that copy blocks of data.
RENDER = ZE_BIT(5) ## Engines that can process both 3D content and compute kernels.
class zes_engine_type_flags_t(c_int):
def __str__(self):
return hex(self.value)
###############################################################################
## @brief Device repair status
class zes_repair_status_v(IntEnum):
UNSUPPORTED = 0 ## The device does not support in-field repairs.
NOT_PERFORMED = 1 ## The device has never been repaired.
PERFORMED = 2 ## The device has been repaired.
class zes_repair_status_t(c_int):
def __str__(self):
return str(zes_repair_status_v(self.value))
###############################################################################
## @brief Device reset reasons
class zes_reset_reason_flags_v(IntEnum):
WEDGED = ZE_BIT(0) ## The device needs to be reset because one or more parts of the hardware
## is wedged
REPAIR = ZE_BIT(1) ## The device needs to be reset in order to complete in-field repairs
class zes_reset_reason_flags_t(c_int):
def __str__(self):
return hex(self.value)
###############################################################################
## @brief Device reset type
class zes_reset_type_v(IntEnum):
WARM = 0 ## Apply warm reset
COLD = 1 ## Apply cold reset
FLR = 2 ## Apply FLR reset
class zes_reset_type_t(c_int):
def __str__(self):
return str(zes_reset_type_v(self.value))
###############################################################################
## @brief Device state
class zes_device_state_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("reset", zes_reset_reason_flags_t), ## [out] Indicates if the device needs to be reset and for what reasons.
## returns 0 (none) or combination of ::zes_reset_reason_flag_t
("repaired", zes_repair_status_t) ## [out] Indicates if the device has been repaired
]
###############################################################################
## @brief Device reset properties
class zes_reset_properties_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("force", ze_bool_t), ## [in] If set to true, all applications that are currently using the
## device will be forcibly killed.
("resetType", zes_reset_type_t) ## [in] Type of reset needs to be performed
]
###############################################################################
## @brief Device universal unique id (UUID)
class zes_uuid_t(Structure):
_fields_ = [
("id", c_ubyte * ZES_MAX_UUID_SIZE) ## [out] opaque data representing a device UUID
]
###############################################################################
## @brief Supported device types
class zes_device_type_v(IntEnum):
GPU = 1 ## Graphics Processing Unit
CPU = 2 ## Central Processing Unit
FPGA = 3 ## Field Programmable Gate Array
MCA = 4 ## Memory Copy Accelerator
VPU = 5 ## Vision Processing Unit
class zes_device_type_t(c_int):
def __str__(self):
return str(zes_device_type_v(self.value))
###############################################################################
## @brief Supported device property flags
class zes_device_property_flags_v(IntEnum):
INTEGRATED = ZE_BIT(0) ## Device is integrated with the Host.
SUBDEVICE = ZE_BIT(1) ## Device handle used for query represents a sub-device.
ECC = ZE_BIT(2) ## Device supports error correction memory access.
ONDEMANDPAGING = ZE_BIT(3) ## Device supports on-demand page-faulting.
class zes_device_property_flags_t(c_int):
def __str__(self):
return hex(self.value)
###############################################################################
## @brief Device properties
class zes_device_properties_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("core", ze_device_properties_t), ## [out] (Deprecated, use ::zes_uuid_t in the extended structure) Core
## device properties
("numSubdevices", c_ulong), ## [out] Number of sub-devices. A value of 0 indicates that this device
## doesn't have sub-devices.
("serialNumber", c_char * ZES_STRING_PROPERTY_SIZE), ## [out] Manufacturing serial number (NULL terminated string value). This
## value is intended to reflect the Part ID/SoC ID assigned by
## manufacturer that is unique for a SoC. Will be set to the string
## "unknown" if this cannot be determined for the device.
("boardNumber", c_char * ZES_STRING_PROPERTY_SIZE), ## [out] Manufacturing board number (NULL terminated string value).
## Alternatively "boardSerialNumber", this value is intended to reflect
## the string printed on board label by manufacturer. Will be set to the
## string "unknown" if this cannot be determined for the device.
("brandName", c_char * ZES_STRING_PROPERTY_SIZE), ## [out] Brand name of the device (NULL terminated string value). Will be
## set to the string "unknown" if this cannot be determined for the
## device.
("modelName", c_char * ZES_STRING_PROPERTY_SIZE), ## [out] Model name of the device (NULL terminated string value). Will be
## set to the string "unknown" if this cannot be determined for the
## device.
("vendorName", c_char * ZES_STRING_PROPERTY_SIZE), ## [out] Vendor name of the device (NULL terminated string value). Will
## be set to the string "unknown" if this cannot be determined for the
## device.
("driverVersion", c_char * ZES_STRING_PROPERTY_SIZE) ## [out] Installed driver version (NULL terminated string value). Will be
## set to the string "unknown" if this cannot be determined for the
## device.
]
###############################################################################
## @brief Device properties
class zes_device_ext_properties_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("uuid", zes_uuid_t), ## [out] universal unique identifier. Note: uuid obtained from Sysman API
## is the same as from core API. Subdevices will have their own uuid.
("type", zes_device_type_t), ## [out] generic device type
("flags", zes_device_property_flags_t) ## [out] 0 (none) or a valid combination of ::zes_device_property_flag_t
]
###############################################################################
## @brief Contains information about a process that has an open connection with
## this device
##
## @details
## - The application can use the process ID to query the OS for the owner
## and the path to the executable.
class zes_process_state_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("processId", c_ulong), ## [out] Host OS process ID.
("memSize", c_ulonglong), ## [out] Device memory size in bytes allocated by this process (may not
## necessarily be resident on the device at the time of reading).
("sharedSize", c_ulonglong), ## [out] The size of shared device memory mapped into this process (may
## not necessarily be resident on the device at the time of reading).
("engines", zes_engine_type_flags_t) ## [out] Bitfield of accelerator engine types being used by this process.
]
###############################################################################
## @brief PCI address
class zes_pci_address_t(Structure):
_fields_ = [
("domain", c_ulong), ## [out] BDF domain
("bus", c_ulong), ## [out] BDF bus
("device", c_ulong), ## [out] BDF device
("function", c_ulong) ## [out] BDF function
]
###############################################################################
## @brief PCI speed
class zes_pci_speed_t(Structure):
_fields_ = [
("gen", c_int32_t), ## [out] The link generation. A value of -1 means that this property is
## unknown.
("width", c_int32_t), ## [out] The number of lanes. A value of -1 means that this property is
## unknown.
("maxBandwidth", c_int64_t) ## [out] The maximum bandwidth in bytes/sec (sum of all lanes). A value
## of -1 means that this property is unknown.
]
###############################################################################
## @brief Static PCI properties
class zes_pci_properties_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("address", zes_pci_address_t), ## [out] The BDF address
("maxSpeed", zes_pci_speed_t), ## [out] Fastest port configuration supported by the device (sum of all
## lanes)
("haveBandwidthCounters", ze_bool_t), ## [out] Indicates whether the `rxCounter` and `txCounter` members of
## ::zes_pci_stats_t will have valid values
("havePacketCounters", ze_bool_t), ## [out] Indicates whether the `packetCounter` member of
## ::zes_pci_stats_t will have a valid value
("haveReplayCounters", ze_bool_t) ## [out] Indicates whether the `replayCounter` member of
## ::zes_pci_stats_t will have a valid value
]
###############################################################################
## @brief PCI link status
class zes_pci_link_status_v(IntEnum):
UNKNOWN = 0 ## The link status could not be determined
GOOD = 1 ## The link is up and operating as expected
QUALITY_ISSUES = 2 ## The link is up but has quality and/or bandwidth degradation
STABILITY_ISSUES = 3 ## The link has stability issues and preventing workloads making forward
## progress
class zes_pci_link_status_t(c_int):
def __str__(self):
return str(zes_pci_link_status_v(self.value))
###############################################################################
## @brief PCI link quality degradation reasons
class zes_pci_link_qual_issue_flags_v(IntEnum):
REPLAYS = ZE_BIT(0) ## A significant number of replays are occurring
SPEED = ZE_BIT(1) ## There is a degradation in the maximum bandwidth of the link
class zes_pci_link_qual_issue_flags_t(c_int):
def __str__(self):
return hex(self.value)
###############################################################################
## @brief PCI link stability issues
class zes_pci_link_stab_issue_flags_v(IntEnum):
RETRAINING = ZE_BIT(0) ## Link retraining has occurred to deal with quality issues
class zes_pci_link_stab_issue_flags_t(c_int):
def __str__(self):
return hex(self.value)
###############################################################################
## @brief Dynamic PCI state
class zes_pci_state_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("status", zes_pci_link_status_t), ## [out] The current status of the port
("qualityIssues", zes_pci_link_qual_issue_flags_t), ## [out] If status is ::ZES_PCI_LINK_STATUS_QUALITY_ISSUES,
## then this gives a combination of ::zes_pci_link_qual_issue_flag_t for
## quality issues that have been detected;
## otherwise, 0 indicates there are no quality issues with the link at
## this time."
("stabilityIssues", zes_pci_link_stab_issue_flags_t), ## [out] If status is ::ZES_PCI_LINK_STATUS_STABILITY_ISSUES,
## then this gives a combination of ::zes_pci_link_stab_issue_flag_t for
## reasons for the connection instability;
## otherwise, 0 indicates there are no connection stability issues at
## this time."
("speed", zes_pci_speed_t) ## [out] The current port configure speed
]
###############################################################################
## @brief PCI bar types
class zes_pci_bar_type_v(IntEnum):
MMIO = 0 ## MMIO registers
ROM = 1 ## ROM aperture
MEM = 2 ## Device memory
class zes_pci_bar_type_t(c_int):
def __str__(self):
return str(zes_pci_bar_type_v(self.value))
###############################################################################
## @brief Properties of a pci bar
class zes_pci_bar_properties_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("type", zes_pci_bar_type_t), ## [out] The type of bar
("index", c_ulong), ## [out] The index of the bar
("base", c_ulonglong), ## [out] Base address of the bar.
("size", c_ulonglong) ## [out] Size of the bar.
]
###############################################################################
## @brief Properties of a pci bar, including the resizable bar.
class zes_pci_bar_properties_1_2_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("type", zes_pci_bar_type_t), ## [out] The type of bar
("index", c_ulong), ## [out] The index of the bar
("base", c_ulonglong), ## [out] Base address of the bar.
("size", c_ulonglong), ## [out] Size of the bar.
("resizableBarSupported", ze_bool_t), ## [out] Support for Resizable Bar on this device.
("resizableBarEnabled", ze_bool_t) ## [out] Resizable Bar enabled on this device
]
###############################################################################
## @brief PCI stats counters
##
## @details
## - Percent replays is calculated by taking two snapshots (s1, s2) and
## using the equation: %replay = 10^6 * (s2.replayCounter -
## s1.replayCounter) / (s2.maxBandwidth * (s2.timestamp - s1.timestamp))
## - Percent throughput is calculated by taking two snapshots (s1, s2) and
## using the equation: %bw = 10^6 * ((s2.rxCounter - s1.rxCounter) +
## (s2.txCounter - s1.txCounter)) / (s2.maxBandwidth * (s2.timestamp -
## s1.timestamp))
class zes_pci_stats_t(Structure):
_fields_ = [
("timestamp", c_ulonglong), ## [out] Monotonic timestamp counter in microseconds when the measurement
## was made.
## This timestamp should only be used to calculate delta time between
## snapshots of this structure.
## Never take the delta of this timestamp with the timestamp from a
## different structure since they are not guaranteed to have the same base.
## The absolute value of the timestamp is only valid during within the
## application and may be different on the next execution.
("replayCounter", c_ulonglong), ## [out] Monotonic counter for the number of replay packets (sum of all
## lanes). Will always be 0 when the `haveReplayCounters` member of
## ::zes_pci_properties_t is FALSE.
("packetCounter", c_ulonglong), ## [out] Monotonic counter for the number of packets (sum of all lanes).
## Will always be 0 when the `havePacketCounters` member of
## ::zes_pci_properties_t is FALSE.
("rxCounter", c_ulonglong), ## [out] Monotonic counter for the number of bytes received (sum of all
## lanes). Will always be 0 when the `haveBandwidthCounters` member of
## ::zes_pci_properties_t is FALSE.
("txCounter", c_ulonglong), ## [out] Monotonic counter for the number of bytes transmitted (including
## replays) (sum of all lanes). Will always be 0 when the
## `haveBandwidthCounters` member of ::zes_pci_properties_t is FALSE.
("speed", zes_pci_speed_t) ## [out] The current speed of the link (sum of all lanes)
]
###############################################################################
## @brief Overclock domains.
class zes_overclock_domain_v(IntEnum):
CARD = 1 ## Overclocking card level properties such as temperature limits.
PACKAGE = 2 ## Overclocking package level properties such as power limits.
GPU_ALL = 4 ## Overclocking a GPU that has all accelerator assets on the same PLL/VR.
GPU_RENDER_COMPUTE = 8 ## Overclocking a GPU with render and compute assets on the same PLL/VR.
GPU_RENDER = 16 ## Overclocking a GPU with render assets on its own PLL/VR.
GPU_COMPUTE = 32 ## Overclocking a GPU with compute assets on its own PLL/VR.
GPU_MEDIA = 64 ## Overclocking a GPU with media assets on its own PLL/VR.
VRAM = 128 ## Overclocking device local memory.
ADM = 256 ## Overclocking LLC/L4 cache.
class zes_overclock_domain_t(c_int):
def __str__(self):
return str(zes_overclock_domain_v(self.value))
###############################################################################
## @brief Overclock controls.
class zes_overclock_control_v(IntEnum):
VF = 1 ## This control permits setting a custom V-F curve.
FREQ_OFFSET = 2 ## The V-F curve of the overclock domain can be shifted up or down using
## this control.
VMAX_OFFSET = 4 ## This control is used to increase the permitted voltage above the
## shipped voltage maximum.
FREQ = 8 ## This control permits direct changes to the operating frequency.
VOLT_LIMIT = 16 ## This control prevents frequencies that would push the voltage above
## this value, typically used by V-F scanners.
POWER_SUSTAINED_LIMIT = 32 ## This control changes the sustained power limit (PL1).
POWER_BURST_LIMIT = 64 ## This control changes the burst power limit (PL2).
POWER_PEAK_LIMIT = 128 ## his control changes the peak power limit (PL4).
ICCMAX_LIMIT = 256 ## This control changes the value of IccMax..
TEMP_LIMIT = 512 ## This control changes the value of TjMax.
ITD_DISABLE = 1024 ## This control permits disabling the adaptive voltage feature ITD
ACM_DISABLE = 2048 ## This control permits disabling the adaptive voltage feature ACM.
class zes_overclock_control_t(c_int):
def __str__(self):
return str(zes_overclock_control_v(self.value))
###############################################################################
## @brief Overclock modes.
class zes_overclock_mode_v(IntEnum):
MODE_OFF = 0 ## Overclock mode is off
MODE_STOCK = 2 ## Stock (manufacturing settings) are being used.
MODE_ON = 3 ## Overclock mode is on.
MODE_UNAVAILABLE = 4 ## Overclocking is unavailable at this time since the system is running
## on battery.
MODE_DISABLED = 5 ## Overclock mode is disabled.
class zes_overclock_mode_t(c_int):
def __str__(self):
return str(zes_overclock_mode_v(self.value))
###############################################################################
## @brief Overclock control states.
class zes_control_state_v(IntEnum):
STATE_UNSET = 0 ## No overclock control has not been changed by the driver since the last
## boot/reset.
STATE_ACTIVE = 2 ## The overclock control has been set and it is active.
STATE_DISABLED = 3 ## The overclock control value has been disabled due to the current power
## configuration (typically when running on DC).
class zes_control_state_t(c_int):
def __str__(self):
return str(zes_control_state_v(self.value))
###############################################################################
## @brief Overclock pending actions.
class zes_pending_action_v(IntEnum):
PENDING_NONE = 0 ## There no pending actions. .
PENDING_IMMINENT = 1 ## The requested change is in progress and should complete soon.
PENDING_COLD_RESET = 2 ## The requested change requires a device cold reset (hotplug, system
## boot).
PENDING_WARM_RESET = 3 ## The requested change requires a device warm reset (PCIe FLR).
class zes_pending_action_t(c_int):
def __str__(self):
return str(zes_pending_action_v(self.value))
###############################################################################
## @brief Overclock V-F curve programing.
class zes_vf_program_type_v(IntEnum):
VF_ARBITRARY = 0 ## Can program an arbitrary number of V-F points up to the maximum number
## and each point can have arbitrary voltage and frequency values within
## the min/max/step limits
VF_FREQ_FIXED = 1 ## Can only program the voltage for the V-F points that it reads back -
## the frequency of those points cannot be changed
VF_VOLT_FIXED = 2 ## Can only program the frequency for the V-F points that is reads back -
## the voltage of each point cannot be changed.
class zes_vf_program_type_t(c_int):
def __str__(self):
return str(zes_vf_program_type_v(self.value))
###############################################################################
## @brief VF type
class zes_vf_type_v(IntEnum):
VOLT = 0 ## VF Voltage point
FREQ = 1 ## VF Frequency point
class zes_vf_type_t(c_int):
def __str__(self):
return str(zes_vf_type_v(self.value))
###############################################################################
## @brief VF type
class zes_vf_array_type_v(IntEnum):
USER_VF_ARRAY = 0 ## User V-F array
DEFAULT_VF_ARRAY = 1 ## Default V-F array
LIVE_VF_ARRAY = 2 ## Live V-F array
class zes_vf_array_type_t(c_int):
def __str__(self):
return str(zes_vf_array_type_v(self.value))
###############################################################################
## @brief Overclock properties
##
## @details
## - Information on the overclock domain type and all the contols that are
## part of the domain.
class zes_overclock_properties_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("domainType", zes_overclock_domain_t), ## [out] The hardware block that this overclock domain controls (GPU,
## VRAM, ...)
("AvailableControls", c_ulong), ## [out] Returns the overclock controls that are supported (a bit for
## each of enum ::zes_overclock_control_t). If no bits are set, the
## domain doesn't support overclocking.
("VFProgramType", zes_vf_program_type_t), ## [out] Type of V-F curve programming that is permitted:.
("NumberOfVFPoints", c_ulong) ## [out] Number of VF points that can be programmed - max_num_points
]
###############################################################################
## @brief Overclock Control properties
##
## @details
## - Provides all the control capabilities supported by the device for the
## overclock domain.
class zes_control_property_t(Structure):
_fields_ = [
("MinValue", c_double), ## [out] This provides information about the limits of the control value
## so that the driver can calculate the set of valid values.
("MaxValue", c_double), ## [out] This provides information about the limits of the control value
## so that the driver can calculate the set of valid values.
("StepValue", c_double), ## [out] This provides information about the limits of the control value
## so that the driver can calculate the set of valid values.
("RefValue", c_double), ## [out] The reference value provides the anchor point, UIs can combine
## this with the user offset request to show the anticipated improvement.
("DefaultValue", c_double) ## [out] The shipped out-of-box position of this control. Driver can
## request this value at any time to return to the out-of-box behavior.
]
###############################################################################
## @brief Overclock VF properties
##
## @details
## - Provides all the VF capabilities supported by the device for the
## overclock domain.
class zes_vf_property_t(Structure):
_fields_ = [
("MinFreq", c_double), ## [out] Read the minimum frequency that can be be programmed in the
## custom V-F point..
("MaxFreq", c_double), ## [out] Read the maximum frequency that can be be programmed in the
## custom V-F point..
("StepFreq", c_double), ## [out] Read the frequency step that can be be programmed in the custom
## V-F point..
("MinVolt", c_double), ## [out] Read the minimum voltage that can be be programmed in the custom
## V-F point..
("MaxVolt", c_double), ## [out] Read the maximum voltage that can be be programmed in the custom
## V-F point..
("StepVolt", c_double) ## [out] Read the voltage step that can be be programmed in the custom
## V-F point.
]
###############################################################################
## @brief Diagnostic results
class zes_diag_result_v(IntEnum):
NO_ERRORS = 0 ## Diagnostic completed without finding errors to repair
ABORT = 1 ## Diagnostic had problems running tests
FAIL_CANT_REPAIR = 2 ## Diagnostic had problems setting up repairs
REBOOT_FOR_REPAIR = 3 ## Diagnostics found errors, setup for repair and reboot is required to
## complete the process
class zes_diag_result_t(c_int):
def __str__(self):
return str(zes_diag_result_v(self.value))
###############################################################################
## @brief Diagnostic test index to use for the very first test.
ZES_DIAG_FIRST_TEST_INDEX = 0x0
###############################################################################
## @brief Diagnostic test index to use for the very last test.
ZES_DIAG_LAST_TEST_INDEX = 0xFFFFFFFF
###############################################################################
## @brief Diagnostic test
class zes_diag_test_t(Structure):
_fields_ = [
("index", c_ulong), ## [out] Index of the test
("name", c_char * ZES_STRING_PROPERTY_SIZE) ## [out] Name of the test
]
###############################################################################
## @brief Diagnostics test suite properties
class zes_diag_properties_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("onSubdevice", ze_bool_t), ## [out] True if the resource is located on a sub-device; false means
## that the resource is on the device of the calling Sysman handle
("subdeviceId", c_ulong), ## [out] If onSubdevice is true, this gives the ID of the sub-device
("name", c_char * ZES_STRING_PROPERTY_SIZE), ## [out] Name of the diagnostics test suite
("haveTests", ze_bool_t) ## [out] Indicates if this test suite has individual tests which can be
## run separately (use the function ::zesDiagnosticsGetTests() to get the
## list of these tests)
]
###############################################################################
## @brief ECC State
class zes_device_ecc_state_v(IntEnum):
UNAVAILABLE = 0 ## None
ENABLED = 1 ## ECC enabled.
DISABLED = 2 ## ECC disabled.
class zes_device_ecc_state_t(c_int):
def __str__(self):
return str(zes_device_ecc_state_v(self.value))
###############################################################################
## @brief State Change Requirements
class zes_device_action_v(IntEnum):
NONE = 0 ## No action.
WARM_CARD_RESET = 1 ## Warm reset of the card.
COLD_CARD_RESET = 2 ## Cold reset of the card.
COLD_SYSTEM_REBOOT = 3 ## Cold reboot of the system.
class zes_device_action_t(c_int):
def __str__(self):
return str(zes_device_action_v(self.value))
###############################################################################
## @brief ECC State Descriptor
class zes_device_ecc_desc_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("state", zes_device_ecc_state_t) ## [out] ECC state
]
###############################################################################
## @brief ECC State
class zes_device_ecc_properties_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("currentState", zes_device_ecc_state_t), ## [out] Current ECC state
("pendingState", zes_device_ecc_state_t), ## [out] Pending ECC state
("pendingAction", zes_device_action_t) ## [out] Pending action
]
###############################################################################
## @brief Accelerator engine groups
class zes_engine_group_v(IntEnum):
ALL = 0 ## Access information about all engines combined.
COMPUTE_ALL = 1 ## Access information about all compute engines combined. Compute engines
## can only process compute kernels (no 3D content).
MEDIA_ALL = 2 ## Access information about all media engines combined.
COPY_ALL = 3 ## Access information about all copy (blitter) engines combined.
COMPUTE_SINGLE = 4 ## Access information about a single compute engine - this is an engine
## that can process compute kernels. Note that single engines may share
## the same underlying accelerator resources as other engines so activity
## of such an engine may not be indicative of the underlying resource
## utilization - use ::ZES_ENGINE_GROUP_3D_RENDER_COMPUTE_ALL for that.
RENDER_SINGLE = 5 ## Access information about a single render engine - this is an engine
## that can process both 3D content and compute kernels. Note that single
## engines may share the same underlying accelerator resources as other
## engines so activity of such an engine may not be indicative of the
## underlying resource utilization - use
## ::ZES_ENGINE_GROUP_3D_RENDER_COMPUTE_ALL for that.
MEDIA_DECODE_SINGLE = 6 ## [DEPRECATED] No longer supported.
MEDIA_ENCODE_SINGLE = 7 ## [DEPRECATED] No longer supported.
COPY_SINGLE = 8 ## Access information about a single media encode engine. Note that
## single engines may share the same underlying accelerator resources as
## other engines so activity of such an engine may not be indicative of
## the underlying resource utilization - use ::ZES_ENGINE_GROUP_COPY_ALL
## for that.
MEDIA_ENHANCEMENT_SINGLE = 9 ## Access information about a single media enhancement engine. Note that
## single engines may share the same underlying accelerator resources as
## other engines so activity of such an engine may not be indicative of
## the underlying resource utilization - use ::ZES_ENGINE_GROUP_MEDIA_ALL
## for that.
_3D_SINGLE = 10 ## [DEPRECATED] No longer supported.
_3D_RENDER_COMPUTE_ALL = 11 ## [DEPRECATED] No longer supported.
RENDER_ALL = 12 ## Access information about all render engines combined. Render engines
## are those than process both 3D content and compute kernels.
_3D_ALL = 13 ## [DEPRECATED] No longer supported.
MEDIA_CODEC_SINGLE = 14 ## Access information about a single media engine. Note that single
## engines may share the same underlying accelerator resources as other
## engines so activity of such an engine may not be indicative of the
## underlying resource utilization - use ::ZES_ENGINE_GROUP_MEDIA_ALL for
## that.
class zes_engine_group_t(c_int):
def __str__(self):
return str(zes_engine_group_v(self.value))
###############################################################################
## @brief Engine group properties
class zes_engine_properties_t(Structure):
_fields_ = [
("stype", zes_structure_type_t), ## [in] type of this structure
("pNext", c_void_p), ## [in,out][optional] must be null or a pointer to an extension-specific
## structure (i.e. contains stype and pNext).
("type", zes_engine_group_t), ## [out] The engine group
("onSubdevice", ze_bool_t), ## [out] True if this resource is located on a sub-device; false means
## that the resource is on the device of the calling Sysman handle
("subdeviceId", c_ulong) ## [out] If onSubdevice is true, this gives the ID of the sub-device
]
###############################################################################
## @brief Engine activity counters
##
## @details
## - Percent utilization is calculated by taking two snapshots (s1, s2) and
## using the equation: %util = (s2.activeTime - s1.activeTime) /
## (s2.timestamp - s1.timestamp)
## - The `activeTime` time units are implementation-specific since the
## value is only intended to be used for calculating utilization
## percentage.
## - The `timestamp` should only be used to calculate delta between
## snapshots of this structure.
## - The application should never take the delta of `timestamp` with the
## timestamp from a different structure since they are not guaranteed to
## have the same base.
## - When taking the delta, the difference between `timestamp` samples
## could be `0`, if the frequency of sampling the snapshots is higher
## than the frequency of the timestamp update.
## - The absolute value of `timestamp` is only valid during within the
## application and may be different on the next execution.
class zes_engine_stats_t(Structure):
_fields_ = [
("activeTime", c_ulonglong), ## [out] Monotonic counter where the resource is actively running
## workloads.
("timestamp", c_ulonglong) ## [out] Monotonic counter when activeTime counter was sampled.
]
###############################################################################
## @brief Event types
class zes_event_type_flags_v(IntEnum):
DEVICE_DETACH = ZE_BIT(0) ## Event is triggered when the device is no longer available (due to a
## reset or being disabled).
DEVICE_ATTACH = ZE_BIT(1) ## Event is triggered after the device is available again.
DEVICE_SLEEP_STATE_ENTER = ZE_BIT(2) ## Event is triggered when the driver is about to put the device into a
## deep sleep state
DEVICE_SLEEP_STATE_EXIT = ZE_BIT(3) ## Event is triggered when the driver is waking the device up from a deep
## sleep state
FREQ_THROTTLED = ZE_BIT(4) ## Event is triggered when the frequency starts being throttled
ENERGY_THRESHOLD_CROSSED = ZE_BIT(5) ## Event is triggered when the energy consumption threshold is reached
## (use ::zesPowerSetEnergyThreshold() to configure).
TEMP_CRITICAL = ZE_BIT(6) ## Event is triggered when the critical temperature is reached (use
## ::zesTemperatureSetConfig() to configure - disabled by default).
TEMP_THRESHOLD1 = ZE_BIT(7) ## Event is triggered when the temperature crosses threshold 1 (use
## ::zesTemperatureSetConfig() to configure - disabled by default).
TEMP_THRESHOLD2 = ZE_BIT(8) ## Event is triggered when the temperature crosses threshold 2 (use
## ::zesTemperatureSetConfig() to configure - disabled by default).
MEM_HEALTH = ZE_BIT(9) ## Event is triggered when the health of device memory changes.
FABRIC_PORT_HEALTH = ZE_BIT(10) ## Event is triggered when the health of fabric ports change.
PCI_LINK_HEALTH = ZE_BIT(11) ## Event is triggered when the health of the PCI link changes.
RAS_CORRECTABLE_ERRORS = ZE_BIT(12) ## Event is triggered when accelerator RAS correctable errors cross
## thresholds (use ::zesRasSetConfig() to configure - disabled by
## default).
RAS_UNCORRECTABLE_ERRORS = ZE_BIT(13) ## Event is triggered when accelerator RAS uncorrectable errors cross
## thresholds (use ::zesRasSetConfig() to configure - disabled by
## default).
DEVICE_RESET_REQUIRED = ZE_BIT(14) ## Event is triggered when the device needs to be reset (use
## ::zesDeviceGetState() to determine the reasons for the reset).
SURVIVABILITY_MODE_DETECTED = ZE_BIT(15) ## Event is triggered when graphics driver encounter an error condition.
class zes_event_type_flags_t(c_int):
def __str__(self):
return hex(self.value)