habana-pyhlml 1.22.2.32__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- META-INF/HABANA_PYHLML-1.22.2.32-PY3-NONE-ANY.RSA +0 -0
- META-INF/HABANA_PYHLML-1.22.2.32-PY3-NONE-ANY.SF +38 -0
- META-INF/MANIFEST.MF +36 -0
- habana_pyhlml-1.22.2.32.dist-info/LICENSE +21 -0
- habana_pyhlml-1.22.2.32.dist-info/METADATA +66 -0
- habana_pyhlml-1.22.2.32.dist-info/RECORD +11 -0
- habana_pyhlml-1.22.2.32.dist-info/WHEEL +5 -0
- habana_pyhlml-1.22.2.32.dist-info/top_level.txt +1 -0
- pyhlml/__init__.py +1 -0
- pyhlml/hlml_error.py +50 -0
- pyhlml/hlml_lib.py +49 -0
- pyhlml/hlml_types.py +284 -0
- pyhlml/main.py +1169 -0
- pyhlml/pyhlml_types_generated.py +268 -0
pyhlml/main.py
ADDED
|
@@ -0,0 +1,1169 @@
|
|
|
1
|
+
import ctypes
|
|
2
|
+
|
|
3
|
+
from sys import modules
|
|
4
|
+
from typing import Tuple
|
|
5
|
+
|
|
6
|
+
import pyhlml.hlml_types as hlml_t
|
|
7
|
+
|
|
8
|
+
from pyhlml.hlml_lib import LibHLML
|
|
9
|
+
from pyhlml.hlml_error import HLMLError, ErrorsAsClass
|
|
10
|
+
|
|
11
|
+
_hlmlOBJ = None
|
|
12
|
+
|
|
13
|
+
def _wrapperInit():
|
|
14
|
+
"""Initialize module-level HLML object and error classes."""
|
|
15
|
+
ErrorsAsClass()
|
|
16
|
+
setattr(modules[__name__], "_hlmlOBJ", LibHLML())
|
|
17
|
+
|
|
18
|
+
def check_return(ret):
|
|
19
|
+
"""Raise HLMLError if ret is not HLML_SUCCESS, otherwise return ret."""
|
|
20
|
+
if (ret != hlml_t.HLML_RETURN.HLML_SUCCESS ):
|
|
21
|
+
raise HLMLError(ret)
|
|
22
|
+
return ret
|
|
23
|
+
|
|
24
|
+
def hlmlInit() -> None:
|
|
25
|
+
"""Initialize HLML. Must be called before any other API can be used."""
|
|
26
|
+
_wrapperInit()
|
|
27
|
+
global _hlmlOBJ
|
|
28
|
+
|
|
29
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_init")
|
|
30
|
+
ret = fn()
|
|
31
|
+
|
|
32
|
+
_hlmlOBJ.inc_ref()
|
|
33
|
+
check_return(ret)
|
|
34
|
+
return None
|
|
35
|
+
|
|
36
|
+
def hlmlInitWithFlags(flags=0) -> None:
|
|
37
|
+
"""Initialize HLML with flags. Only the default flag (0) is supported.
|
|
38
|
+
Args:
|
|
39
|
+
flags (int): Initialization flags (default 0).
|
|
40
|
+
"""
|
|
41
|
+
_wrapperInit()
|
|
42
|
+
global _hlmlOBJ
|
|
43
|
+
|
|
44
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_init_with_flags")
|
|
45
|
+
ret = fn(flags)
|
|
46
|
+
|
|
47
|
+
_hlmlOBJ.inc_ref()
|
|
48
|
+
check_return(ret)
|
|
49
|
+
return None
|
|
50
|
+
|
|
51
|
+
def hlmlShutdown() -> None:
|
|
52
|
+
"""Shutdown HLML and release resources. Should be called last."""
|
|
53
|
+
global _hlmlOBJ
|
|
54
|
+
|
|
55
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_shutdown")
|
|
56
|
+
ret = fn()
|
|
57
|
+
|
|
58
|
+
for _ in range(_hlmlOBJ.ref_count):
|
|
59
|
+
_hlmlOBJ.dec_ref()
|
|
60
|
+
check_return(ret)
|
|
61
|
+
return None
|
|
62
|
+
|
|
63
|
+
def hlmlDeviceGetCount() -> int:
|
|
64
|
+
"""Get the number of Habana devices in the system.
|
|
65
|
+
Returns:
|
|
66
|
+
int: Number of Habana devices.
|
|
67
|
+
"""
|
|
68
|
+
global _hlmlOBJ
|
|
69
|
+
count = ctypes.c_uint()
|
|
70
|
+
|
|
71
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_count")
|
|
72
|
+
ret = fn(ctypes.byref(count))
|
|
73
|
+
|
|
74
|
+
check_return(ret)
|
|
75
|
+
return count.value
|
|
76
|
+
|
|
77
|
+
def hlmlDeviceGetHandleByPCIBusID(pci_addr: str) -> hlml_t.HLML_DEVICE.TYPE:
|
|
78
|
+
"""Get device handle by PCI address.
|
|
79
|
+
If there is a single domain, the 'domain' part of the PCI address
|
|
80
|
+
is not required.
|
|
81
|
+
Args:
|
|
82
|
+
pci_addr (str): PCI address of the device.
|
|
83
|
+
Returns:
|
|
84
|
+
HLML_DEVICE.TYPE: Device handle.
|
|
85
|
+
"""
|
|
86
|
+
global _hlmlOBJ
|
|
87
|
+
|
|
88
|
+
device = hlml_t.HLML_DEVICE.TYPE()
|
|
89
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_handle_by_pci_bus_id")
|
|
90
|
+
ret = fn(str.encode(pci_addr), ctypes.byref(device))
|
|
91
|
+
|
|
92
|
+
check_return(ret)
|
|
93
|
+
return device
|
|
94
|
+
|
|
95
|
+
def hlmlDeviceGetHandleByIndex(index: int) -> hlml_t.HLML_DEVICE.TYPE:
|
|
96
|
+
"""Get device handle by index.
|
|
97
|
+
Args:
|
|
98
|
+
index (int): Device index.
|
|
99
|
+
Returns:
|
|
100
|
+
HLML_DEVICE.TYPE: Device handle.
|
|
101
|
+
"""
|
|
102
|
+
global _hlmlOBJ
|
|
103
|
+
device = hlml_t.HLML_DEVICE.TYPE()
|
|
104
|
+
|
|
105
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_handle_by_index")
|
|
106
|
+
ret = fn(index, ctypes.byref(device))
|
|
107
|
+
|
|
108
|
+
check_return(ret)
|
|
109
|
+
return device
|
|
110
|
+
|
|
111
|
+
def hlmlDeviceGetHandleByUUID(uuid: str) -> hlml_t.HLML_DEVICE.TYPE:
|
|
112
|
+
"""Get device handle by UUID (Universal Unique ID).
|
|
113
|
+
Args:
|
|
114
|
+
uuid (str): Device UUID.
|
|
115
|
+
Returns:
|
|
116
|
+
HLML_DEVICE.TYPE: Device handle.
|
|
117
|
+
"""
|
|
118
|
+
global _hlmlOBJ
|
|
119
|
+
device = hlml_t.HLML_DEVICE.TYPE()
|
|
120
|
+
|
|
121
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_handle_by_UUID")
|
|
122
|
+
ret = fn(str.encode(uuid), ctypes.byref(device))
|
|
123
|
+
|
|
124
|
+
check_return(ret)
|
|
125
|
+
return device
|
|
126
|
+
|
|
127
|
+
def hlmlDeviceGetName(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
|
|
128
|
+
"""Get device name from handle.
|
|
129
|
+
Args:
|
|
130
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
131
|
+
Returns:
|
|
132
|
+
bytes: Device name.
|
|
133
|
+
"""
|
|
134
|
+
global _hlmlOBJ
|
|
135
|
+
name = ctypes.create_string_buffer(hlml_t.HLML_DEFINE.HL_FIELD_MAX_SIZE)
|
|
136
|
+
|
|
137
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_name")
|
|
138
|
+
ret = fn(
|
|
139
|
+
device, ctypes.byref(name),
|
|
140
|
+
ctypes.c_uint(hlml_t.HLML_DEFINE.HL_FIELD_MAX_SIZE)
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
check_return(ret)
|
|
144
|
+
return name.value
|
|
145
|
+
|
|
146
|
+
def hlmlDeviceGetPCIInfo(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.c_hlml_pci_info:
|
|
147
|
+
"""Get PCI attributes of the device.
|
|
148
|
+
Args:
|
|
149
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
150
|
+
Returns:
|
|
151
|
+
c_hlml_pci_info: PCI attributes.
|
|
152
|
+
"""
|
|
153
|
+
global _hlmlOBJ
|
|
154
|
+
pci_info = hlml_t.c_hlml_pci_info()
|
|
155
|
+
|
|
156
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_pci_info")
|
|
157
|
+
ret = fn(
|
|
158
|
+
device, ctypes.byref(pci_info),
|
|
159
|
+
ctypes.c_uint(hlml_t.HLML_DEFINE.HL_FIELD_MAX_SIZE)
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
check_return(ret)
|
|
163
|
+
return pci_info
|
|
164
|
+
|
|
165
|
+
def hlmlDeviceGetClockInfo(device: hlml_t.HLML_DEVICE.TYPE, clock_type=0 ) -> int:
|
|
166
|
+
"""Get current speed of the selected clock (MHz).
|
|
167
|
+
Args:
|
|
168
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
169
|
+
clock_type (int): Clock type.
|
|
170
|
+
Returns:
|
|
171
|
+
int: Clock speed in MHz.
|
|
172
|
+
"""
|
|
173
|
+
global _hlmlOBJ
|
|
174
|
+
speed = ctypes.c_uint()
|
|
175
|
+
|
|
176
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_clock_info")
|
|
177
|
+
ret = fn(device, clock_type, ctypes.byref(speed))
|
|
178
|
+
|
|
179
|
+
check_return(ret)
|
|
180
|
+
return speed.value
|
|
181
|
+
|
|
182
|
+
def hlmlDeviceGetMaxClockInfo(device: hlml_t.HLML_DEVICE.TYPE, clock_type=0 ) -> int:
|
|
183
|
+
"""Get maximum speed of the selected clock (MHz).
|
|
184
|
+
Args:
|
|
185
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
186
|
+
clock_type (int): Clock type.
|
|
187
|
+
Returns:
|
|
188
|
+
int: Maximum clock speed in MHz.
|
|
189
|
+
"""
|
|
190
|
+
global _hlmlOBJ
|
|
191
|
+
speed = ctypes.c_uint()
|
|
192
|
+
|
|
193
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_max_clock_info")
|
|
194
|
+
ret = fn(device, clock_type, ctypes.byref(speed))
|
|
195
|
+
|
|
196
|
+
check_return(ret)
|
|
197
|
+
return speed.value
|
|
198
|
+
|
|
199
|
+
def hlmlDeviceGetClockLimitInfo(device: hlml_t.HLML_DEVICE.TYPE, clock_type=0 ) -> int:
|
|
200
|
+
"""Get frequency limit of the selected clock (MHz).
|
|
201
|
+
Args:
|
|
202
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
203
|
+
clock_type (int): Clock type.
|
|
204
|
+
Returns:
|
|
205
|
+
int: Frequency limit in MHz.
|
|
206
|
+
"""
|
|
207
|
+
global _hlmlOBJ
|
|
208
|
+
speed = ctypes.c_uint()
|
|
209
|
+
|
|
210
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_clock_limit_info")
|
|
211
|
+
ret = fn(device, clock_type, ctypes.byref(speed))
|
|
212
|
+
|
|
213
|
+
check_return(ret)
|
|
214
|
+
return speed.value
|
|
215
|
+
|
|
216
|
+
def hlmlDeviceGetUtilizationRates(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.c_hlml_utilization:
|
|
217
|
+
"""Get device utilization rates over the past second.
|
|
218
|
+
Args:
|
|
219
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
220
|
+
Returns:
|
|
221
|
+
c_hlml_utilization: Utilization rates.
|
|
222
|
+
"""
|
|
223
|
+
global _hlmlOBJ
|
|
224
|
+
hlml_util = hlml_t.c_hlml_utilization()
|
|
225
|
+
|
|
226
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_utilization_rates")
|
|
227
|
+
ret = fn(device, ctypes.byref(hlml_util))
|
|
228
|
+
|
|
229
|
+
check_return(ret)
|
|
230
|
+
return hlml_util
|
|
231
|
+
|
|
232
|
+
def hlmlDeviceGetProcessUtilization(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.c_hlml_process_utilization:
|
|
233
|
+
"""Get process utilization rates (as a percentage) over the past second.
|
|
234
|
+
Args:
|
|
235
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
236
|
+
Returns:
|
|
237
|
+
c_hlml_process_utilization: Process utilization rates.
|
|
238
|
+
"""
|
|
239
|
+
global _hlmlOBJ
|
|
240
|
+
hlml_util = hlml_t.c_hlml_process_utilization()
|
|
241
|
+
|
|
242
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_process_utilization")
|
|
243
|
+
ret = fn(device, ctypes.byref(hlml_util))
|
|
244
|
+
|
|
245
|
+
check_return(ret)
|
|
246
|
+
return hlml_util
|
|
247
|
+
|
|
248
|
+
def hlmlDeviceGetMemoryInfo(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.c_hlml_memory:
|
|
249
|
+
"""Get total, used, and free memory in bytes.
|
|
250
|
+
Args:
|
|
251
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
252
|
+
Returns:
|
|
253
|
+
c_hlml_memory: Memory info.
|
|
254
|
+
"""
|
|
255
|
+
global _hlmlOBJ
|
|
256
|
+
hlml_mem = hlml_t.c_hlml_memory()
|
|
257
|
+
|
|
258
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_memory_info")
|
|
259
|
+
ret = fn(device, ctypes.byref(hlml_mem))
|
|
260
|
+
|
|
261
|
+
check_return(ret)
|
|
262
|
+
return hlml_mem
|
|
263
|
+
|
|
264
|
+
def hlmlDeviceGetTemperature(
|
|
265
|
+
device: hlml_t.HLML_DEVICE.TYPE, sensor_type: hlml_t.HLML_TEMP_SENS.TYPE) -> int:
|
|
266
|
+
"""Get current temperature (Celsius) of the selected sensor.
|
|
267
|
+
Args:
|
|
268
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
269
|
+
sensor_type (HLML_TEMP_SENS.TYPE): Sensor type.
|
|
270
|
+
Returns:
|
|
271
|
+
int: Temperature in Celsius.
|
|
272
|
+
"""
|
|
273
|
+
global _hlmlOBJ
|
|
274
|
+
temp = ctypes.c_uint()
|
|
275
|
+
|
|
276
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_temperature")
|
|
277
|
+
ret = fn(device, sensor_type, ctypes.byref(temp))
|
|
278
|
+
|
|
279
|
+
check_return(ret)
|
|
280
|
+
return temp.value
|
|
281
|
+
|
|
282
|
+
def hlmlDeviceGetTemperatureThreshold(device: hlml_t.HLML_DEVICE.TYPE, threshold_type: int) -> int:
|
|
283
|
+
"""Get temperature threshold (Celsius) of the requested type.
|
|
284
|
+
Args:
|
|
285
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
286
|
+
threshold_type (int): Threshold type.
|
|
287
|
+
Returns:
|
|
288
|
+
int: Threshold temperature in Celsius.
|
|
289
|
+
"""
|
|
290
|
+
global _hlmlOBJ
|
|
291
|
+
temp = ctypes.c_uint()
|
|
292
|
+
|
|
293
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_temperature_threshold")
|
|
294
|
+
ret = fn(device, threshold_type, ctypes.byref(temp))
|
|
295
|
+
|
|
296
|
+
check_return(ret)
|
|
297
|
+
return temp.value
|
|
298
|
+
|
|
299
|
+
def hlmlDeviceGetPersistenceMode(device: hlml_t.HLML_DEVICE.TYPE) -> int:
|
|
300
|
+
"""Get persistence mode of the device.
|
|
301
|
+
Args:
|
|
302
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
303
|
+
Returns:
|
|
304
|
+
int: Persistence mode.
|
|
305
|
+
"""
|
|
306
|
+
global _hlmlOBJ
|
|
307
|
+
mode = ctypes.c_uint()
|
|
308
|
+
|
|
309
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_persistence_mode")
|
|
310
|
+
ret = fn(device, ctypes.byref(mode))
|
|
311
|
+
|
|
312
|
+
check_return(ret)
|
|
313
|
+
return mode.value
|
|
314
|
+
|
|
315
|
+
def hlmlDeviceGetPerformanceState(device: hlml_t.HLML_DEVICE.TYPE) -> int:
|
|
316
|
+
"""Get performance state of the device.
|
|
317
|
+
Args:
|
|
318
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
319
|
+
Returns:
|
|
320
|
+
int: Performance state.
|
|
321
|
+
"""
|
|
322
|
+
global _hlmlOBJ
|
|
323
|
+
p_state = ctypes.c_uint()
|
|
324
|
+
|
|
325
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_performance_state")
|
|
326
|
+
ret = fn(device, ctypes.byref(p_state))
|
|
327
|
+
|
|
328
|
+
check_return(ret)
|
|
329
|
+
return p_state.value
|
|
330
|
+
|
|
331
|
+
def hlmlDeviceGetSupportedPerformanceStates(device: hlml_t.HLML_DEVICE.TYPE) -> tuple:
|
|
332
|
+
"""Get all supported performance states for the device.
|
|
333
|
+
The returned array is of size HLML_PSTATE_NUM_SUPPORTED and contains a contiguous
|
|
334
|
+
list of performance states that the device supports.
|
|
335
|
+
If the number of supported performance states is less than HLML_PSTATE_NUM_SUPPORTED,
|
|
336
|
+
the remaining entries in the array will be set to HLML_PSTATE_UNKNOWN.
|
|
337
|
+
Args:
|
|
338
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
339
|
+
Returns:
|
|
340
|
+
HLML_P_STATES array: Supported performance states.
|
|
341
|
+
"""
|
|
342
|
+
global _hlmlOBJ
|
|
343
|
+
p_states = (hlml_t.HLML_P_STATES.TYPE * hlml_t.HLML_PSTATE_NUM_SUPPORTED)()
|
|
344
|
+
|
|
345
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_supported_performance_states")
|
|
346
|
+
ret = fn(device, ctypes.byref(p_states), hlml_t.HLML_PSTATE_NUM_SUPPORTED)
|
|
347
|
+
|
|
348
|
+
check_return(ret)
|
|
349
|
+
return p_states
|
|
350
|
+
|
|
351
|
+
def hlmlDeviceGetPowerUsage(device: hlml_t.HLML_DEVICE.TYPE) -> int:
|
|
352
|
+
"""Get power usage for the device in mW.
|
|
353
|
+
Args:
|
|
354
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
355
|
+
Returns:
|
|
356
|
+
int: Power usage in mW.
|
|
357
|
+
"""
|
|
358
|
+
global _hlmlOBJ
|
|
359
|
+
power = ctypes.c_uint()
|
|
360
|
+
|
|
361
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_power_usage")
|
|
362
|
+
ret = fn(device, ctypes.byref(power))
|
|
363
|
+
|
|
364
|
+
check_return(ret)
|
|
365
|
+
return power.value
|
|
366
|
+
|
|
367
|
+
def hlmlDeviceSetPowerManagementLimit(device: hlml_t.HLML_DEVICE.TYPE, limit : ctypes.c_uint) -> None:
|
|
368
|
+
"""Set power management limit on this device in mW.
|
|
369
|
+
Args:
|
|
370
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
371
|
+
limit (ctypes.c_uint): Power limit in mW.
|
|
372
|
+
"""
|
|
373
|
+
global _hlmlOBJ
|
|
374
|
+
|
|
375
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_set_power_management_limit")
|
|
376
|
+
ret = fn(device, limit)
|
|
377
|
+
|
|
378
|
+
check_return(ret)
|
|
379
|
+
return None
|
|
380
|
+
|
|
381
|
+
def hlmlDeviceGetPowerManagementDefaultLimit(device: hlml_t.HLML_DEVICE.TYPE) -> int:
|
|
382
|
+
"""Get default power management limit on this device in mW.
|
|
383
|
+
Args:
|
|
384
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
385
|
+
Returns:
|
|
386
|
+
int: Default power limit in mW.
|
|
387
|
+
"""
|
|
388
|
+
global _hlmlOBJ
|
|
389
|
+
power = ctypes.c_uint()
|
|
390
|
+
|
|
391
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_power_management_default_limit")
|
|
392
|
+
ret = fn(device, ctypes.byref(power))
|
|
393
|
+
|
|
394
|
+
check_return(ret)
|
|
395
|
+
return power.value
|
|
396
|
+
|
|
397
|
+
def hlmlDeviceGetECCMode(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.hlml_ecc_mode:
|
|
398
|
+
"""Get current and pending ECC modes of the device.
|
|
399
|
+
Args:
|
|
400
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
401
|
+
Returns:
|
|
402
|
+
hlml_ecc_mode: ECC mode info with 'current' and 'pending' attributes.
|
|
403
|
+
"""
|
|
404
|
+
global _hlmlOBJ
|
|
405
|
+
out = hlml_t.hlml_ecc_mode()
|
|
406
|
+
current = ctypes.c_uint()
|
|
407
|
+
pending = ctypes.c_uint()
|
|
408
|
+
|
|
409
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_ecc_mode")
|
|
410
|
+
ret = fn(device, ctypes.byref(current), ctypes.byref(pending))
|
|
411
|
+
|
|
412
|
+
check_return(ret)
|
|
413
|
+
setattr(out, "current", current)
|
|
414
|
+
setattr(out, "pending", pending)
|
|
415
|
+
|
|
416
|
+
return out
|
|
417
|
+
|
|
418
|
+
def hlmlDeviceGetTotalECCErrors(device: hlml_t.HLML_DEVICE.TYPE, error_type: hlml_t.HLML_MEMORY_ERROR.TYPE, counter_type: hlml_t.HLML_ECC_COUNTER) -> int:
|
|
419
|
+
"""Get number of ECC errors for a device since last reset or driver reinstall.
|
|
420
|
+
Args:
|
|
421
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
422
|
+
error_type (HLML_MEMORY_ERROR.TYPE): Error type to count.
|
|
423
|
+
counter_type (HLML_ECC_COUNTER): Counter type to use.
|
|
424
|
+
Returns:
|
|
425
|
+
int: Number of ECC errors.
|
|
426
|
+
"""
|
|
427
|
+
global _hlmlOBJ
|
|
428
|
+
count = ctypes.c_longlong()
|
|
429
|
+
|
|
430
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_total_ecc_errors")
|
|
431
|
+
ret = fn(device, error_type, counter_type, ctypes.byref(count))
|
|
432
|
+
|
|
433
|
+
check_return(ret)
|
|
434
|
+
return count.value
|
|
435
|
+
|
|
436
|
+
def hlmlDeviceGetMemoryErrorCounter(device: hlml_t.HLML_DEVICE.TYPE, error_type: hlml_t.HLML_MEMORY_ERROR.TYPE, counter_type: hlml_t.HLML_ECC_COUNTER.TYPE, location: hlml_t.HLML_MEMORY_LOCATION.TYPE) -> int:
|
|
437
|
+
"""Get number of ECC errors for a device at a specified memory location.
|
|
438
|
+
The number is from the last reset or driver reinstall. Currently, only the
|
|
439
|
+
number of corrected errors is supported.
|
|
440
|
+
Args:
|
|
441
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
442
|
+
error_type (HLML_MEMORY_ERROR.TYPE): Error type to count.
|
|
443
|
+
counter_type (HLML_ECC_COUNTER.TYPE): Counter type to use.
|
|
444
|
+
location (HLML_MEMORY_LOCATION.TYPE): Memory location.
|
|
445
|
+
Returns:
|
|
446
|
+
int: Number of ECC errors.
|
|
447
|
+
"""
|
|
448
|
+
global _hlmlOBJ
|
|
449
|
+
ecc_count = ctypes.c_longlong()
|
|
450
|
+
|
|
451
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_memory_error_counter")
|
|
452
|
+
ret = fn(device, error_type, counter_type, location, ctypes.byref(ecc_count))
|
|
453
|
+
|
|
454
|
+
check_return(ret)
|
|
455
|
+
return ecc_count.value
|
|
456
|
+
|
|
457
|
+
def hlmlDeviceGetUUID(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
|
|
458
|
+
"""Get UUID (Universal Unique ID) of the device.
|
|
459
|
+
Args:
|
|
460
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
461
|
+
Returns:
|
|
462
|
+
bytes: Device UUID.
|
|
463
|
+
"""
|
|
464
|
+
global _hlmlOBJ
|
|
465
|
+
name_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
|
|
466
|
+
name = ctypes.create_string_buffer(name_len)
|
|
467
|
+
|
|
468
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_uuid")
|
|
469
|
+
ret = fn(device, ctypes.byref(name), name_len)
|
|
470
|
+
|
|
471
|
+
check_return(ret)
|
|
472
|
+
return name.value
|
|
473
|
+
|
|
474
|
+
def hlmlDeviceGetMinorNumber(device: hlml_t.HLML_DEVICE.TYPE) -> int:
|
|
475
|
+
"""Get minor number of the device (maps to device node file
|
|
476
|
+
at /sys/class/accel/accel[minor]).
|
|
477
|
+
Args:
|
|
478
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
479
|
+
Returns:
|
|
480
|
+
int: Minor number.
|
|
481
|
+
"""
|
|
482
|
+
global _hlmlOBJ
|
|
483
|
+
number = ctypes.c_uint()
|
|
484
|
+
|
|
485
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_minor_number")
|
|
486
|
+
ret = fn(device, ctypes.byref(number))
|
|
487
|
+
|
|
488
|
+
check_return(ret)
|
|
489
|
+
return number.value
|
|
490
|
+
|
|
491
|
+
def hlmlEventSetCreate() -> hlml_t.HLML_EVENT_SET.TYPE:
|
|
492
|
+
"""Create an empty set of events.
|
|
493
|
+
Returns:
|
|
494
|
+
HLML_EVENT_SET.TYPE: Empty event set.
|
|
495
|
+
"""
|
|
496
|
+
global _hlmlOBJ
|
|
497
|
+
st = hlml_t.HLML_EVENT_SET.TYPE()
|
|
498
|
+
|
|
499
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_event_set_create")
|
|
500
|
+
ret = fn(ctypes.byref(st))
|
|
501
|
+
|
|
502
|
+
check_return(ret)
|
|
503
|
+
return st
|
|
504
|
+
|
|
505
|
+
def hlmlEventSetFree(st: hlml_t.HLML_EVENT_SET.TYPE) -> None:
|
|
506
|
+
"""Release a set of events.
|
|
507
|
+
Args:
|
|
508
|
+
st (HLML_EVENT_SET.TYPE): Event set to release.
|
|
509
|
+
"""
|
|
510
|
+
global _hlmlOBJ
|
|
511
|
+
|
|
512
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_event_set_free")
|
|
513
|
+
ret = fn(st)
|
|
514
|
+
|
|
515
|
+
check_return(ret)
|
|
516
|
+
return None
|
|
517
|
+
|
|
518
|
+
def hlmlDeviceRegisterEvents(
|
|
519
|
+
device: hlml_t.HLML_DEVICE.TYPE, event_types: int,
|
|
520
|
+
st: hlml_t.HLML_EVENT_SET.TYPE
|
|
521
|
+
) -> None:
|
|
522
|
+
"""Start recording events on device and add events to set.
|
|
523
|
+
Args:
|
|
524
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
525
|
+
event_types (int): Event types to record.
|
|
526
|
+
st (HLML_EVENT_SET.TYPE): Event set (buffer) to be written to.
|
|
527
|
+
"""
|
|
528
|
+
global _hlmlOBJ
|
|
529
|
+
|
|
530
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_register_events")
|
|
531
|
+
ret = fn(device, event_types, st)
|
|
532
|
+
|
|
533
|
+
check_return(ret)
|
|
534
|
+
return None
|
|
535
|
+
|
|
536
|
+
def hlmlEventSetWait(st: hlml_t.HLML_EVENT_SET.TYPE, timeout: int) -> hlml_t.c_hlml_event_data:
|
|
537
|
+
"""Wait for events and deliver event data.
|
|
538
|
+
If any events are available at the time of the call, function returns immediately.
|
|
539
|
+
If there are no events available, it waits until an event arrives or the specified
|
|
540
|
+
timeout is reached.
|
|
541
|
+
Args:
|
|
542
|
+
st (HLML_EVENT_SET.TYPE): Event set (buffer) to be written to.
|
|
543
|
+
timeout (int): Maximum time to wait for an event.
|
|
544
|
+
Returns:
|
|
545
|
+
c_hlml_event_data: Event data.
|
|
546
|
+
"""
|
|
547
|
+
global _hlmlOBJ
|
|
548
|
+
data = hlml_t.c_hlml_event_data()
|
|
549
|
+
|
|
550
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_event_set_wait")
|
|
551
|
+
ret = fn(st, ctypes.byref(data), timeout)
|
|
552
|
+
|
|
553
|
+
check_return(ret)
|
|
554
|
+
return data
|
|
555
|
+
|
|
556
|
+
def hlmlDeviceGetMACInfo(
|
|
557
|
+
device: hlml_t.HLML_DEVICE.TYPE, count=20, start=1) -> tuple:
|
|
558
|
+
"""Get MAC addresses of device.
|
|
559
|
+
Args:
|
|
560
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
561
|
+
count (int): Number of addresses to return.
|
|
562
|
+
start (int): Index to start at.
|
|
563
|
+
Returns:
|
|
564
|
+
c_hlml_mac_info array: MAC addresses.
|
|
565
|
+
"""
|
|
566
|
+
global _hlmlOBJ
|
|
567
|
+
mac = (hlml_t.c_hlml_mac_info * count)()
|
|
568
|
+
actual_info_count = ctypes.c_int()
|
|
569
|
+
|
|
570
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_mac_info")
|
|
571
|
+
ret = fn(device, ctypes.byref(mac), count, start, ctypes.byref(actual_info_count))
|
|
572
|
+
|
|
573
|
+
check_return(ret)
|
|
574
|
+
return mac
|
|
575
|
+
|
|
576
|
+
def hlmlDeviceGetHLRevision(device: hlml_t.HLML_DEVICE.TYPE) -> int:
|
|
577
|
+
"""Get HL revision of the device.
|
|
578
|
+
Args:
|
|
579
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
580
|
+
Returns:
|
|
581
|
+
int: HL revision.
|
|
582
|
+
"""
|
|
583
|
+
global _hlmlOBJ
|
|
584
|
+
rev = ctypes.c_int()
|
|
585
|
+
|
|
586
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_hl_revision")
|
|
587
|
+
ret = fn(device, ctypes.byref(rev))
|
|
588
|
+
|
|
589
|
+
check_return(ret)
|
|
590
|
+
return rev.value
|
|
591
|
+
|
|
592
|
+
def hlmlDeviceGetPCBInfo(device: hlml_t.HLML_DEVICE.TYPE) -> hlml_t.c_hlml_pcb_info:
|
|
593
|
+
"""Get PCB info of the device.
|
|
594
|
+
Args:
|
|
595
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
596
|
+
Returns:
|
|
597
|
+
c_hlml_pcb_info: PCB info.
|
|
598
|
+
"""
|
|
599
|
+
global _hlmlOBJ
|
|
600
|
+
pcb = hlml_t.c_hlml_pcb_info()
|
|
601
|
+
|
|
602
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_pcb_info")
|
|
603
|
+
ret = fn(device, ctypes.byref(pcb))
|
|
604
|
+
|
|
605
|
+
check_return(ret)
|
|
606
|
+
return pcb
|
|
607
|
+
|
|
608
|
+
def hlmlDeviceGetSerial(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
|
|
609
|
+
"""Get unique board serial number.
|
|
610
|
+
Args:
|
|
611
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
612
|
+
Returns:
|
|
613
|
+
bytes: Serial number.
|
|
614
|
+
"""
|
|
615
|
+
global _hlmlOBJ
|
|
616
|
+
ser_len = hlml_t.HLML_DEFINE.HL_FIELD_MAX_SIZE
|
|
617
|
+
ser = ctypes.create_string_buffer(ser_len)
|
|
618
|
+
|
|
619
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_serial")
|
|
620
|
+
ret = fn(device, ctypes.byref(ser), ser_len)
|
|
621
|
+
|
|
622
|
+
check_return(ret)
|
|
623
|
+
return ser.value
|
|
624
|
+
|
|
625
|
+
def hlmlDeviceGetModuleID(device: hlml_t.HLML_DEVICE.TYPE) -> int:
|
|
626
|
+
"""Get module ID configured on the device.
|
|
627
|
+
Args:
|
|
628
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
629
|
+
Returns:
|
|
630
|
+
int: Module ID.
|
|
631
|
+
"""
|
|
632
|
+
global _hlmlOBJ
|
|
633
|
+
module_id = ctypes.c_uint()
|
|
634
|
+
|
|
635
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_module_id")
|
|
636
|
+
ret = fn(device, ctypes.byref(module_id))
|
|
637
|
+
|
|
638
|
+
check_return(ret)
|
|
639
|
+
return module_id.value
|
|
640
|
+
|
|
641
|
+
def hlmlDeviceGetBoardID(device: hlml_t.HLML_DEVICE.TYPE) -> int:
|
|
642
|
+
"""Get device board ID (slot number between 0 and 7).
|
|
643
|
+
Args:
|
|
644
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
645
|
+
Returns:
|
|
646
|
+
int: Board ID.
|
|
647
|
+
"""
|
|
648
|
+
global _hlmlOBJ
|
|
649
|
+
brd = ctypes.c_uint()
|
|
650
|
+
|
|
651
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_board_id")
|
|
652
|
+
ret = fn(device, ctypes.byref(brd))
|
|
653
|
+
|
|
654
|
+
check_return(ret)
|
|
655
|
+
return brd.value
|
|
656
|
+
|
|
657
|
+
def hlmlDeviceGetPCIEThroughput(device: hlml_t.HLML_DEVICE.TYPE, counter_type: int) -> int:
|
|
658
|
+
"""Get PCIe utilization information (over 10ms interval).
|
|
659
|
+
Args:
|
|
660
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
661
|
+
counter_type (int): 0 for TX, 1 for RX.
|
|
662
|
+
Returns:
|
|
663
|
+
int: PCIe throughput.
|
|
664
|
+
"""
|
|
665
|
+
global _hlmlOBJ
|
|
666
|
+
pcie = ctypes.c_uint()
|
|
667
|
+
|
|
668
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_pcie_throughput")
|
|
669
|
+
ret = fn(device, counter_type, ctypes.byref(pcie))
|
|
670
|
+
|
|
671
|
+
check_return(ret)
|
|
672
|
+
return pcie.value
|
|
673
|
+
|
|
674
|
+
def hlmlDeviceGetPCIEReplayCounter(device: hlml_t.HLML_DEVICE.TYPE) -> int:
|
|
675
|
+
"""Get PCIe replay counter.
|
|
676
|
+
Args:
|
|
677
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
678
|
+
Returns:
|
|
679
|
+
int: Replay counter.
|
|
680
|
+
"""
|
|
681
|
+
global _hlmlOBJ
|
|
682
|
+
pcie = ctypes.c_uint()
|
|
683
|
+
|
|
684
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_pcie_replay_counter")
|
|
685
|
+
ret = fn(device, ctypes.byref(pcie))
|
|
686
|
+
|
|
687
|
+
check_return(ret)
|
|
688
|
+
return pcie.value
|
|
689
|
+
|
|
690
|
+
def hlmlDeviceGetCurrPCIELinkGeneration(device: hlml_t.HLML_DEVICE.TYPE) -> int:
|
|
691
|
+
"""Get current PCIe link generation.
|
|
692
|
+
Args:
|
|
693
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
694
|
+
Returns:
|
|
695
|
+
int: PCIe link generation.
|
|
696
|
+
"""
|
|
697
|
+
global _hlmlOBJ
|
|
698
|
+
link = ctypes.c_uint()
|
|
699
|
+
|
|
700
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_curr_pcie_link_generation")
|
|
701
|
+
ret = fn(device, ctypes.byref(link))
|
|
702
|
+
|
|
703
|
+
check_return(ret)
|
|
704
|
+
return link.value
|
|
705
|
+
|
|
706
|
+
def hlmlDeviceGetCurrPCIELinkWidth(device: hlml_t.HLML_DEVICE.TYPE) -> int:
|
|
707
|
+
"""Get current PCIe link width.
|
|
708
|
+
Args:
|
|
709
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
710
|
+
Returns:
|
|
711
|
+
int: PCIe link width.
|
|
712
|
+
"""
|
|
713
|
+
global _hlmlOBJ
|
|
714
|
+
width = ctypes.c_uint()
|
|
715
|
+
|
|
716
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_curr_pcie_link_width")
|
|
717
|
+
ret = fn(device, ctypes.byref(width))
|
|
718
|
+
|
|
719
|
+
check_return(ret)
|
|
720
|
+
return width.value
|
|
721
|
+
|
|
722
|
+
def hlmlDeviceGetCurrentClocksThrottleReasons(device: hlml_t.HLML_DEVICE.TYPE) -> int:
|
|
723
|
+
"""Get current clocks throttle reason.
|
|
724
|
+
Args:
|
|
725
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
726
|
+
Returns:
|
|
727
|
+
int: Throttle reason code.
|
|
728
|
+
"""
|
|
729
|
+
global _hlmlOBJ
|
|
730
|
+
reason = ctypes.c_ulonglong()
|
|
731
|
+
|
|
732
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_current_clocks_throttle_reasons")
|
|
733
|
+
ret = fn(device, ctypes.byref(reason))
|
|
734
|
+
|
|
735
|
+
check_return(ret)
|
|
736
|
+
return reason.value
|
|
737
|
+
|
|
738
|
+
def hlmlDeviceGetTotalEnergyConsumption(device: hlml_t.HLML_DEVICE.TYPE) -> int:
|
|
739
|
+
"""Get total energy consumption in mJ since last driver reload.
|
|
740
|
+
Args:
|
|
741
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
742
|
+
Returns:
|
|
743
|
+
int: Total energy consumption in mJ.
|
|
744
|
+
"""
|
|
745
|
+
global _hlmlOBJ
|
|
746
|
+
energy = ctypes.c_ulonglong()
|
|
747
|
+
|
|
748
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_total_energy_consumption")
|
|
749
|
+
ret = fn(device, ctypes.byref(energy))
|
|
750
|
+
|
|
751
|
+
check_return(ret)
|
|
752
|
+
return energy.value
|
|
753
|
+
|
|
754
|
+
def hlmlDeviceGetMacAddrInfo(device: hlml_t.HLML_DEVICE.TYPE) -> Tuple[Tuple[int, int], Tuple[int, int]]:
|
|
755
|
+
"""Get masks for supported and external ports.
|
|
756
|
+
Args:
|
|
757
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
758
|
+
Returns:
|
|
759
|
+
Tuple[Tuple[int, int], Tuple[int, int]]: (mask, ext_mask), where:
|
|
760
|
+
mask: Bitmask of supported ports.
|
|
761
|
+
ext_mask: Bitmask of external ports (subset of supported).
|
|
762
|
+
"""
|
|
763
|
+
global _hlmlOBJ
|
|
764
|
+
mask = (ctypes.c_uint64 * 2)()
|
|
765
|
+
ext_mask = (ctypes.c_uint64 * 2)()
|
|
766
|
+
|
|
767
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_get_mac_addr_info")
|
|
768
|
+
ret = fn(device, ctypes.byref(mask), ctypes.byref(ext_mask))
|
|
769
|
+
|
|
770
|
+
check_return(ret)
|
|
771
|
+
return (mask[0], mask[1]), (ext_mask[0], ext_mask[1])
|
|
772
|
+
|
|
773
|
+
def hlmlDeviceNicGetLink(device: hlml_t.HLML_DEVICE.TYPE, port: int) -> bool:
|
|
774
|
+
"""Get NIC link status (up/down) for the requested port.
|
|
775
|
+
Args:
|
|
776
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
777
|
+
port (int): Port number.
|
|
778
|
+
Returns:
|
|
779
|
+
bool: Port status. True if up, False if down.
|
|
780
|
+
"""
|
|
781
|
+
global _hlmlOBJ
|
|
782
|
+
up = ctypes.c_bool()
|
|
783
|
+
|
|
784
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_nic_get_link")
|
|
785
|
+
ret = fn(device, ctypes.c_uint32(port), ctypes.byref(up))
|
|
786
|
+
|
|
787
|
+
check_return(ret)
|
|
788
|
+
return up.value
|
|
789
|
+
|
|
790
|
+
def hlmlDeviceNicGetStatistics(device: hlml_t.HLML_DEVICE.TYPE, port: int, num_of_counts: int = None) -> hlml_t.c_hlml_nic_stats_info:
|
|
791
|
+
"""Get NIC statistics for the requested port.
|
|
792
|
+
Args:
|
|
793
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
794
|
+
port (int): Port number.
|
|
795
|
+
num_of_counts (int, optional): Number of counts to allocate.
|
|
796
|
+
Returns:
|
|
797
|
+
c_hlml_nic_stats_info: NIC statistics.
|
|
798
|
+
"""
|
|
799
|
+
global _hlmlOBJ
|
|
800
|
+
nic_stats_info = hlml_t.c_hlml_nic_stats_info(port, num_of_counts)
|
|
801
|
+
|
|
802
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_nic_get_statistics")
|
|
803
|
+
ret = fn(device, ctypes.byref(nic_stats_info))
|
|
804
|
+
|
|
805
|
+
check_return(ret)
|
|
806
|
+
return nic_stats_info
|
|
807
|
+
|
|
808
|
+
def hlmlGetHLMLVersion() -> bytes:
|
|
809
|
+
"""Get version of HLML library.
|
|
810
|
+
Returns:
|
|
811
|
+
bytes: HLML library version.
|
|
812
|
+
"""
|
|
813
|
+
global _hlmlOBJ
|
|
814
|
+
ver_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
|
|
815
|
+
version = ctypes.create_string_buffer(ver_len)
|
|
816
|
+
|
|
817
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_get_hlml_version")
|
|
818
|
+
ret = fn(version, ctypes.c_uint(ver_len))
|
|
819
|
+
|
|
820
|
+
check_return(ret)
|
|
821
|
+
return version.value
|
|
822
|
+
|
|
823
|
+
def hlmlGetDriverVersion() -> bytes:
|
|
824
|
+
"""Get version of driver.
|
|
825
|
+
Returns:
|
|
826
|
+
bytes: Driver version.
|
|
827
|
+
"""
|
|
828
|
+
global _hlmlOBJ
|
|
829
|
+
ver_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
|
|
830
|
+
version = ctypes.create_string_buffer(ver_len)
|
|
831
|
+
|
|
832
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_get_driver_version")
|
|
833
|
+
ret = fn(version, ctypes.c_uint(ver_len))
|
|
834
|
+
|
|
835
|
+
check_return(ret)
|
|
836
|
+
return version.value
|
|
837
|
+
|
|
838
|
+
def hlmlGetNicDriverVersion() -> bytes:
|
|
839
|
+
"""Get version of NIC driver.
|
|
840
|
+
Returns:
|
|
841
|
+
bytes: NIC driver version.
|
|
842
|
+
"""
|
|
843
|
+
global _hlmlOBJ
|
|
844
|
+
ver_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
|
|
845
|
+
version = ctypes.create_string_buffer(ver_len)
|
|
846
|
+
|
|
847
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_get_nic_driver_version")
|
|
848
|
+
ret = fn(version, ctypes.c_uint(ver_len))
|
|
849
|
+
|
|
850
|
+
check_return(ret)
|
|
851
|
+
return version.value
|
|
852
|
+
|
|
853
|
+
def hlmlDeviceGetModelNumber(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
|
|
854
|
+
"""Get model number of the device.
|
|
855
|
+
Args:
|
|
856
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
857
|
+
Returns:
|
|
858
|
+
bytes: Model number.
|
|
859
|
+
"""
|
|
860
|
+
global _hlmlOBJ
|
|
861
|
+
num_len = hlml_t.HLML_DEFINE.HL_FIELD_MAX_SIZE
|
|
862
|
+
num_str = ctypes.create_string_buffer(num_len)
|
|
863
|
+
|
|
864
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_get_model_number")
|
|
865
|
+
ret = fn(device, num_str, ctypes.c_uint(num_len))
|
|
866
|
+
|
|
867
|
+
check_return(ret)
|
|
868
|
+
return num_str.value
|
|
869
|
+
|
|
870
|
+
def hlmlDeviceGetFirmwareFITVersion(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
|
|
871
|
+
"""Get firmware FIT version.
|
|
872
|
+
Args:
|
|
873
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
874
|
+
Returns:
|
|
875
|
+
bytes: Firmware FIT version.
|
|
876
|
+
"""
|
|
877
|
+
global _hlmlOBJ
|
|
878
|
+
ver_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
|
|
879
|
+
ver_str = ctypes.create_string_buffer(ver_len)
|
|
880
|
+
|
|
881
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_get_firmware_fit_version")
|
|
882
|
+
ret = fn(device, ver_str, ctypes.c_uint(ver_len))
|
|
883
|
+
|
|
884
|
+
check_return(ret)
|
|
885
|
+
return ver_str.value
|
|
886
|
+
|
|
887
|
+
def hlmlDeviceGetFirmwareSPIVersion(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
|
|
888
|
+
"""Get firmware SPI version.
|
|
889
|
+
Args:
|
|
890
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
891
|
+
Returns:
|
|
892
|
+
bytes: Firmware SPI version.
|
|
893
|
+
"""
|
|
894
|
+
global _hlmlOBJ
|
|
895
|
+
ver_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
|
|
896
|
+
ver_str = ctypes.create_string_buffer(ver_len)
|
|
897
|
+
|
|
898
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_get_firmware_spi_version")
|
|
899
|
+
ret = fn(device, ver_str, ctypes.c_uint(ver_len))
|
|
900
|
+
|
|
901
|
+
check_return(ret)
|
|
902
|
+
return ver_str.value
|
|
903
|
+
|
|
904
|
+
def hlmlDeviceGetFWBootVersion(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
|
|
905
|
+
"""Get firmware boot version.
|
|
906
|
+
Args:
|
|
907
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
908
|
+
Returns:
|
|
909
|
+
bytes: Firmware boot version.
|
|
910
|
+
"""
|
|
911
|
+
global _hlmlOBJ
|
|
912
|
+
ver_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
|
|
913
|
+
ver_str = ctypes.create_string_buffer(ver_len)
|
|
914
|
+
|
|
915
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_get_fw_boot_version")
|
|
916
|
+
ret = fn(device, ver_str, ctypes.c_uint(ver_len))
|
|
917
|
+
|
|
918
|
+
check_return(ret)
|
|
919
|
+
return ver_str.value
|
|
920
|
+
|
|
921
|
+
def hlmlDeviceGetFWOSVersion(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
|
|
922
|
+
"""Get firmware OS version.
|
|
923
|
+
Args:
|
|
924
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
925
|
+
Returns:
|
|
926
|
+
bytes: Firmware OS version.
|
|
927
|
+
"""
|
|
928
|
+
global _hlmlOBJ
|
|
929
|
+
ver_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
|
|
930
|
+
ver_str = ctypes.create_string_buffer(ver_len)
|
|
931
|
+
|
|
932
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_get_fw_os_version")
|
|
933
|
+
ret = fn(device, ver_str, ctypes.c_uint(ver_len))
|
|
934
|
+
|
|
935
|
+
check_return(ret)
|
|
936
|
+
return ver_str.value
|
|
937
|
+
|
|
938
|
+
def hlmlDeviceGetCPLDVersion(device: hlml_t.HLML_DEVICE.TYPE) -> bytes:
|
|
939
|
+
"""Get CPLD version.
|
|
940
|
+
Args:
|
|
941
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
942
|
+
Returns:
|
|
943
|
+
bytes: CPLD version.
|
|
944
|
+
"""
|
|
945
|
+
global _hlmlOBJ
|
|
946
|
+
ver_len = hlml_t.COMMON_DEFINE.VERSION_MAX_LEN
|
|
947
|
+
ver_str = ctypes.create_string_buffer(ver_len)
|
|
948
|
+
|
|
949
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_get_cpld_version")
|
|
950
|
+
ret = fn(device, ver_str, ctypes.c_uint(ver_len))
|
|
951
|
+
|
|
952
|
+
check_return(ret)
|
|
953
|
+
return ver_str.value
|
|
954
|
+
|
|
955
|
+
def hlmlDeviceClearCpuAffinity(device: hlml_t.HLML_DEVICE.TYPE) -> None:
|
|
956
|
+
"""Clear device's CPU affinity.
|
|
957
|
+
Args:
|
|
958
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
959
|
+
"""
|
|
960
|
+
global _hlmlOBJ
|
|
961
|
+
|
|
962
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_clear_cpu_affinity")
|
|
963
|
+
ret = fn(device)
|
|
964
|
+
|
|
965
|
+
check_return(ret)
|
|
966
|
+
return None
|
|
967
|
+
|
|
968
|
+
def hlmlDeviceGetCpuAffinity(device: hlml_t.HLML_DEVICE.TYPE, cpu_set_size: int):
|
|
969
|
+
"""Get CPU affinity set associated with a device.
|
|
970
|
+
Args:
|
|
971
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
972
|
+
cpu_set_size (int): Size of the CPU set.
|
|
973
|
+
Returns:
|
|
974
|
+
array: CPU set.
|
|
975
|
+
"""
|
|
976
|
+
global _hlmlOBJ
|
|
977
|
+
cpu_set = (ctypes.c_ulong * cpu_set_size)()
|
|
978
|
+
|
|
979
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_cpu_affinity")
|
|
980
|
+
ret = fn(device, cpu_set_size, ctypes.byref(cpu_set))
|
|
981
|
+
|
|
982
|
+
check_return(ret)
|
|
983
|
+
return cpu_set
|
|
984
|
+
|
|
985
|
+
def hlmlDeviceGetCpuAffinityWithinScope(device: hlml_t.HLML_DEVICE.TYPE, cpu_set_size: int, scope: hlml_t.HLML_AFFINITY_SCOPE.TYPE):
|
|
986
|
+
"""Get CPU affinity set associated with a device.
|
|
987
|
+
Args:
|
|
988
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
989
|
+
cpu_set_size (int): Size of the CPU set.
|
|
990
|
+
scope (HLML_AFFINITY_SCOPE.TYPE): Affinity scope.
|
|
991
|
+
Returns:
|
|
992
|
+
array: CPU set.
|
|
993
|
+
"""
|
|
994
|
+
global _hlmlOBJ
|
|
995
|
+
cpu_set = (ctypes.c_ulong * cpu_set_size)()
|
|
996
|
+
|
|
997
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_cpu_affinity_within_scope")
|
|
998
|
+
ret = fn(device, cpu_set_size, ctypes.byref(cpu_set), scope)
|
|
999
|
+
|
|
1000
|
+
check_return(ret)
|
|
1001
|
+
return cpu_set
|
|
1002
|
+
|
|
1003
|
+
def hlmlDeviceGetMemoryAffinity(device: hlml_t.HLML_DEVICE.TYPE, node_set_size: int, scope: hlml_t.HLML_AFFINITY_SCOPE.TYPE):
|
|
1004
|
+
"""Get memory affinity set associated with a device.
|
|
1005
|
+
Args:
|
|
1006
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
1007
|
+
node_set_size (int): Size of the node set.
|
|
1008
|
+
scope (HLML_AFFINITY_SCOPE.TYPE): Affinity scope.
|
|
1009
|
+
Returns:
|
|
1010
|
+
array: Node set.
|
|
1011
|
+
"""
|
|
1012
|
+
global _hlmlOBJ
|
|
1013
|
+
node_set = (ctypes.c_ulong * node_set_size)()
|
|
1014
|
+
|
|
1015
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_memory_affinity")
|
|
1016
|
+
ret = fn(device, node_set_size, ctypes.byref(node_set), scope)
|
|
1017
|
+
|
|
1018
|
+
check_return(ret)
|
|
1019
|
+
return node_set
|
|
1020
|
+
|
|
1021
|
+
def hlmlDeviceSetCpuAffinity(device: hlml_t.HLML_DEVICE.TYPE) -> None:
|
|
1022
|
+
"""Set CPU affinity for a device.
|
|
1023
|
+
Args:
|
|
1024
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
1025
|
+
"""
|
|
1026
|
+
global _hlmlOBJ
|
|
1027
|
+
|
|
1028
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_set_cpu_affinity")
|
|
1029
|
+
ret = fn(device)
|
|
1030
|
+
|
|
1031
|
+
check_return(ret)
|
|
1032
|
+
return None
|
|
1033
|
+
|
|
1034
|
+
def hlmlDeviceGetViolationStatus(device: hlml_t.HLML_DEVICE.TYPE, perf_policy: hlml_t.HLML_PERF_POLICY.TYPE) -> hlml_t.c_hlml_violation_time:
|
|
1035
|
+
"""Get violation status of a device for a given performance policy.
|
|
1036
|
+
Args:
|
|
1037
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
1038
|
+
perf_policy (HLML_PERF_POLICY.TYPE): Performance policy type.
|
|
1039
|
+
Returns:
|
|
1040
|
+
c_hlml_violation_time: Violation status, comprised of reference time and violation time.
|
|
1041
|
+
"""
|
|
1042
|
+
global _hlmlOBJ
|
|
1043
|
+
|
|
1044
|
+
violation_time = hlml_t.c_hlml_violation_time()
|
|
1045
|
+
|
|
1046
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_violation_status")
|
|
1047
|
+
ret = fn(device, perf_policy, ctypes.byref(violation_time))
|
|
1048
|
+
|
|
1049
|
+
check_return(ret)
|
|
1050
|
+
return violation_time
|
|
1051
|
+
|
|
1052
|
+
def hlmlDeviceGetReplacedRowsCount(device: hlml_t.HLML_DEVICE.TYPE, cause: hlml_t.HLML_ROW_REPLACEMENT_CAUSE.TYPE) -> int:
|
|
1053
|
+
"""Get number of replaced rows for a given cause.
|
|
1054
|
+
Args:
|
|
1055
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
1056
|
+
cause (HLML_ROW_REPLACEMENT_CAUSE.TYPE): Replacement cause.
|
|
1057
|
+
Returns:
|
|
1058
|
+
int: Number of replaced rows.
|
|
1059
|
+
"""
|
|
1060
|
+
global _hlmlOBJ
|
|
1061
|
+
|
|
1062
|
+
row_count = ctypes.c_uint()
|
|
1063
|
+
|
|
1064
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_replaced_rows")
|
|
1065
|
+
ret = fn(device, cause, ctypes.byref(row_count), None)
|
|
1066
|
+
|
|
1067
|
+
check_return(ret)
|
|
1068
|
+
return row_count.value
|
|
1069
|
+
|
|
1070
|
+
def hlmlDeviceGetReplacedRows(device: hlml_t.HLML_DEVICE.TYPE, cause: hlml_t.HLML_ROW_REPLACEMENT_CAUSE.TYPE, row_count: int):
|
|
1071
|
+
"""Get array of replaced rows for a given cause.
|
|
1072
|
+
Args:
|
|
1073
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
1074
|
+
cause (HLML_ROW_REPLACEMENT_CAUSE.TYPE): Replacement cause.
|
|
1075
|
+
row_count (int): Number of rows to retrieve.
|
|
1076
|
+
Returns:
|
|
1077
|
+
array: Array of hlml_t.c_hlml_row_address structures.
|
|
1078
|
+
"""
|
|
1079
|
+
global _hlmlOBJ
|
|
1080
|
+
|
|
1081
|
+
c_row_count = ctypes.c_uint(row_count)
|
|
1082
|
+
addresses = (hlml_t.c_hlml_row_address * row_count)()
|
|
1083
|
+
|
|
1084
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_replaced_rows")
|
|
1085
|
+
ret = fn(device, cause, ctypes.byref(c_row_count), ctypes.byref(addresses))
|
|
1086
|
+
|
|
1087
|
+
check_return(ret)
|
|
1088
|
+
return addresses
|
|
1089
|
+
|
|
1090
|
+
def hlmlDeviceGetReplacedRowsPendingStatus(device: hlml_t.HLML_DEVICE.TYPE) -> int:
|
|
1091
|
+
"""Get pending status of replaced rows.
|
|
1092
|
+
Args:
|
|
1093
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
1094
|
+
Returns:
|
|
1095
|
+
int: Pending status. True if there are pending replaced rows, False otherwise.
|
|
1096
|
+
"""
|
|
1097
|
+
global _hlmlOBJ
|
|
1098
|
+
|
|
1099
|
+
is_pending = ctypes.c_uint()
|
|
1100
|
+
|
|
1101
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_replaced_rows_pending_status")
|
|
1102
|
+
ret = fn(device, ctypes.byref(is_pending))
|
|
1103
|
+
|
|
1104
|
+
check_return(ret)
|
|
1105
|
+
return is_pending.value
|
|
1106
|
+
|
|
1107
|
+
def hlmlDeviceGetOperationStatus(device: hlml_t.HLML_DEVICE.TYPE) -> str:
|
|
1108
|
+
"""Get operation status of the device.
|
|
1109
|
+
Args:
|
|
1110
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
1111
|
+
Returns:
|
|
1112
|
+
str: Operation status.
|
|
1113
|
+
"""
|
|
1114
|
+
global _hlmlOBJ
|
|
1115
|
+
sts_len = hlml_t.COMMON_DEFINE.STATUS_MAX_LEN
|
|
1116
|
+
sts_str = ctypes.create_string_buffer(sts_len)
|
|
1117
|
+
|
|
1118
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_oper_status")
|
|
1119
|
+
ret = fn(device, sts_str, ctypes.c_uint(sts_len))
|
|
1120
|
+
|
|
1121
|
+
check_return(ret)
|
|
1122
|
+
return sts_str.value
|
|
1123
|
+
|
|
1124
|
+
def hlmlDeviceGetPowerManagementMode(device: hlml_t.HLML_DEVICE.TYPE) -> int:
|
|
1125
|
+
"""Get power management mode of the device.
|
|
1126
|
+
Args:
|
|
1127
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
1128
|
+
Returns:
|
|
1129
|
+
int: Power management mode.
|
|
1130
|
+
"""
|
|
1131
|
+
global _hlmlOBJ
|
|
1132
|
+
mode = ctypes.c_uint()
|
|
1133
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_power_management_mode")
|
|
1134
|
+
ret = fn(device, ctypes.byref(mode))
|
|
1135
|
+
|
|
1136
|
+
check_return(ret)
|
|
1137
|
+
return mode.value
|
|
1138
|
+
|
|
1139
|
+
def hlmlDeviceGetPowerManagementLimit(device: hlml_t.HLML_DEVICE.TYPE) -> int:
|
|
1140
|
+
"""Get power management limit of the device in mW.
|
|
1141
|
+
Args:
|
|
1142
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
1143
|
+
Returns:
|
|
1144
|
+
int: Power management limit in mW.
|
|
1145
|
+
"""
|
|
1146
|
+
global _hlmlOBJ
|
|
1147
|
+
power_max = ctypes.c_uint()
|
|
1148
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_power_management_limit")
|
|
1149
|
+
ret = fn(device, ctypes.byref(power_max))
|
|
1150
|
+
|
|
1151
|
+
check_return(ret)
|
|
1152
|
+
return power_max.value
|
|
1153
|
+
|
|
1154
|
+
def hlmlDeviceGetPowerManagementLimitConstraints(device: hlml_t.HLML_DEVICE.TYPE) -> Tuple[int, int]:
|
|
1155
|
+
"""Get power management limit constraints (min, max) for the device.
|
|
1156
|
+
Args:
|
|
1157
|
+
device (HLML_DEVICE.TYPE): Device handle.
|
|
1158
|
+
Returns:
|
|
1159
|
+
Tuple[int, int]: (min_limit, max_limit)
|
|
1160
|
+
"""
|
|
1161
|
+
global _hlmlOBJ
|
|
1162
|
+
min_limit = ctypes.c_uint()
|
|
1163
|
+
max_limit = ctypes.c_uint()
|
|
1164
|
+
|
|
1165
|
+
fn = _hlmlOBJ.get_func_ptr("hlml_device_get_power_management_limit_constraints")
|
|
1166
|
+
ret = fn(device, ctypes.byref(min_limit), ctypes.byref(max_limit))
|
|
1167
|
+
|
|
1168
|
+
check_return(ret)
|
|
1169
|
+
return min_limit.value, max_limit.value
|