# -*- coding: utf-8 -*-
#####
# Enflame Tech, All Rights Reserved. 2019-2024 Copyright (c)
#####
##
# Python bindings for the EFML library
##
from ctypes import *
from ctypes.util import find_library
import sys
import os
import threading
import string
## C Type mappings ##
## Enums
[docs]efmlLinkSpeed_t = c_uint
[docs]EFML_LINK_SPEED_GEN1 = 1
[docs]EFML_LINK_SPEED_GEN2 = 2
[docs]EFML_LINK_SPEED_GEN3 = 3
[docs]EFML_LINK_SPEED_GEN4 = 4
[docs]EFML_LINK_SPEED_GEN5 = 5
[docs]efmlEslLinkSpeed_t = c_uint
[docs]EFML_ESL_LINK_SPEED_GEN1 = 1
[docs]EFML_ESL_LINK_SPEED_GEN2 = 2
[docs]EFML_ESL_LINK_SPEED_GEN3 = 3
[docs]EFML_ESL_LINK_SPEED_GEN4 = 4
[docs]EFML_ESL_LINK_SPEED_GEN5 = 5
[docs]EFML_ESL_LINK_SPEED_ESM_2P5GT = 16
[docs]EFML_ESL_LINK_SPEED_ESM_5GT = 17
[docs]EFML_ESL_LINK_SPEED_ESM_8GT = 18
[docs]EFML_ESL_LINK_SPEED_ESM_16GT = 19
[docs]EFML_ESL_LINK_SPEED_ESM_20GT = 20
[docs]EFML_ESL_LINK_SPEED_ESM_25GT = 21
[docs]efmlLinkWidth_t = c_uint
[docs]EFML_LINK_WIDTH_X16 = 16
[docs]efmlEslLinkWidth_t = c_uint
[docs]EFML_ESL_LINK_WIDTH_X1 = 1
[docs]EFML_ESL_LINK_WIDTH_X2 = 2
[docs]EFML_ESL_LINK_WIDTH_X4 = 4
[docs]EFML_ESL_LINK_WIDTH_X8 = 8
[docs]EFML_ESL_LINK_WIDTH_X16 = 16
[docs]efmlEslPortType_t = c_uint
## driver version buffer length
[docs]EFML_DRIVER_VER_LEN = 128
## max buffer length
[docs]EFML_MAX_CHAR_BUFF_LEN = 128
[docs]class efmlDeviceInfo_t(Structure):
[docs] _fields_ = [
('name', c_char * EFML_MAX_CHAR_BUFF_LEN),
('vendor_id', c_uint),
('device_id', c_uint),
('domain_id', c_uint),
('bus_id', c_uint),
('dev_id', c_uint),
('func_id', c_uint),
('logic_id', c_uint),
]
[docs]class efmlDevPowerInfo_t(Structure):
[docs] _fields_ = [
('pwr_capability', c_float),
('cur_pwr_consumption', c_float),
]
[docs]class efmlDriverInfo_t(Structure):
[docs] _fields_ = [
('driver_ver', c_char * EFML_DRIVER_VER_LEN),
]
[docs]class efmlDevMemInfo_t(Structure):
[docs] _fields_ = [
('mem_total_size', c_ulonglong),
('mem_used', c_uint),
]
[docs]class efmlClusterHbmMemInfo_t(Structure):
[docs] _fields_ = [
('mem_total_size', c_ulonglong),
('mem_used', c_uint),
]
[docs]class efmlDevClkInfo_t(Structure):
[docs] _fields_ = [
('cur_hbm_clock', c_uint),
('cur_dtu_clock', c_uint),
]
[docs]class efmlDevThermalInfo_t(Structure):
[docs] _fields_ = [
('cur_dev_temp', c_float),
('cur_hbm0_temp', c_float),
('cur_hbm1_temp', c_float),
]
[docs]class efmlDevVoltInfo_t(Structure):
[docs] _fields_ = [
('vdd_dtu', c_float),
('vdd_soc', c_float),
('vdd_hbmqc', c_float),
('vdd_1v8', c_float),
('vdd_vddp', c_float),
]
[docs]class efmlPcieLinkInfo_t(Structure):
[docs] _fields_ = [
('link_speed', c_uint),
('max_link_speed', c_uint),
('link_width', c_uint),
('max_link_width', c_uint),
]
[docs]class efmlPcieThroughputInfo_t(Structure):
[docs] _fields_ = [
('tx_throughput', c_float),
('rx_throughput', c_float),
('tx_nak', c_ulonglong),
('rx_nak', c_ulonglong),
]
[docs]class efmlEslLinkInfo_t(Structure):
[docs] _fields_ = [
('link_speed', c_uint),
('max_link_speed', c_uint),
('link_width', c_uint),
('max_link_width', c_uint),
]
[docs]class efmlEslThroughputInfo_t(Structure):
[docs] _fields_ = [
('tx_throughput', c_float),
('rx_throughput', c_float),
('tx_nak', c_ulonglong),
('rx_nak', c_ulonglong),
]
[docs]class efmlEslPortInfo_t(Structure):
[docs] _fields_ = [
('connected', c_uint),
('uuid', c_char * 16),
('vendor_id', c_uint),
('device_id', c_uint),
('domain_id', c_uint),
('bus_id', c_uint),
('dev_id', c_uint),
('func_id', c_uint),
('port_id', c_uint),
('port_type', efmlEslPortType_t),
('remote_card_id', c_uint),
('remote_uuid', c_char * 16),
('remote_vendor_id', c_uint),
('remote_device_id', c_uint),
('remote_domain_id', c_uint),
('remote_bus_id', c_uint),
('remote_dev_id', c_uint),
('remote_func_id', c_uint),
('remote_port_id', c_uint),
('remote_port_type', efmlEslPortType_t),
]
# handler efml library
## Error Checking ##
[docs]def efmlError(err_code):
if(err_code >= EFML_ERROR_MAX):
raise Exception("error code not supported!")
if(err_code != EFML_SUCCESS):
# raise Exception('error ' + efmlErrorMessage[err_code])
raise Exception('error ' + efmlErrorString(err_code))
[docs]def efmlLoadLibrary():
global efmlLib
if (efmlLib == None):
try:
efmlLib = CDLL('libefml.so')
except OSError as ose:
print('library not found!')
raise
finally:
pass
# function entry list
[docs]efmlFunctionEntryList_cache = dict()
[docs]def efmlGetFunctionEntry(entry_str):
global efmlLib
if entry_str in efmlFunctionEntryList_cache:
return efmlFunctionEntryList_cache[entry_str]
try:
if (efmlLib == None):
efmlError(EFML_ERROR_UNINITIALIZED)
efmlFunctionEntryList_cache[entry_str] = getattr(efmlLib, entry_str)
return efmlFunctionEntryList_cache[entry_str]
finally:
pass
# init device and library
[docs]def efmlInit(no_driver=False):
"""
Init efml libary
parameters:
no_driver(bool): not use kmd
return:
EFML_SUCCESS
"""
efmlLoadLibrary()
func = efmlGetFunctionEntry("EfmlInit")
c_no_driver = c_bool(no_driver)
try:
ret = func(c_no_driver)
efmlError(ret)
except Exception as e:
raise
return ret
# shutdown and release loaded library
[docs]def efmlShutdown():
"""
Close efml libary, release allocated resource
parameters:
None
return:
None
"""
efmlLoadLibrary()
func = efmlGetFunctionEntry("EfmlShutdown")
try:
func()
except Exception as e:
raise
return None
[docs]def efmlErrorString(ret_val):
"""
Translate returned error code to string
parameters:
ret_val (efmlReturn): function return value
return:
string of return value
"""
c_err_info = create_string_buffer(EFML_MAX_CHAR_BUFF_LEN)
fn = efmlGetFunctionEntry("EfmlErrorString")
ret = fn(ret_val, c_err_info)
return c_err_info.value.decode("utf-8")
[docs]def efmlDriverVer():
"""
Get KMD (kernel mode driver) version info
parameters:
None
return:
string of driver version
"""
c_driver_info = create_string_buffer(EFML_DRIVER_VER_LEN)
fn = efmlGetFunctionEntry("EfmlGetDriverVer")
ret = fn(c_driver_info)
efmlError(ret)
return c_driver_info.value
[docs]def efmlLibVer():
"""
Get EFML lib version info
parameters:
None
return:
string of efml lib version
"""
c_efml_ver_info = create_string_buffer(EFML_DRIVER_VER_LEN)
fn = efmlGetFunctionEntry("EfmlGetLibVer")
ret = fn(c_efml_ver_info)
efmlError(ret)
return c_efml_ver_info.value
[docs]def efmlSelDevByIndex(idx):
"""
Select current device by index
parameters:
idx (int): selected device index
return:
None
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
fn = efmlGetFunctionEntry("EfmlSelDevByIndex")
c_idx = c_uint(idx)
ret = fn(c_idx)
efmlError(ret)
[docs]def efmlGetDevCount():
"""
Get total DTU device numbers in the system
parameters:
None
return:
total device numbers
error:
EFML_ERROR_UNINITIALIZED: library not initialized
"""
cnt = c_uint()
fn = efmlGetFunctionEntry("EfmlGetDevCount")
ret = fn(byref(cnt))
efmlError(ret)
return cnt.value
[docs]def efmlGetDevName(idx):
"""
Get DTU device name
parameters:
idx (int): selected device index
return:
device name in string
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_idx = c_uint(idx)
c_name = create_string_buffer(EFML_MAX_CHAR_BUFF_LEN)
fn = efmlGetFunctionEntry("EfmlGetDevName")
ret = fn(c_idx, c_name)
efmlError(ret)
return c_name.value
[docs]def efmlGetDevUuid(idx):
"""
Get DTU device UUID(Universally Unique Identifier)
parameters:
idx (int): selected device index
return:
device UUID in string
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_idx = c_uint(idx)
c_uuid = create_string_buffer(EFML_MAX_CHAR_BUFF_LEN)
fn = efmlGetFunctionEntry("EfmlGetDevUuid")
ret = fn(c_idx, c_uuid)
efmlError(ret)
return c_uuid.value
[docs]def efmlGetDevSn(idx):
"""
Get DTU device SN info(Serial Number)
parameters:
idx (int): selected device index
return:
device SN in string
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_idx = c_uint(idx)
c_sn = create_string_buffer(EFML_MAX_CHAR_BUFF_LEN)
fn = efmlGetFunctionEntry("EfmlGetDevSn")
ret = fn(c_idx, c_sn)
efmlError(ret)
return c_sn.value
[docs]def efmlGetDevPn(idx):
"""
Get DTU device PN info(Part Number)
parameters:
idx (int): selected device index
return:
device PN in string
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_idx = c_uint(idx)
c_pn = create_string_buffer(EFML_MAX_CHAR_BUFF_LEN)
fn = efmlGetFunctionEntry("EfmlGetDevPn")
ret = fn(c_idx, c_pn)
efmlError(ret)
return c_pn.value
[docs]def efmlGetFwVersion(idx):
"""
Get DTU firmware version
parameters:
idx (int): selected device index
return:
DTU firmware version in string
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_idx = c_uint(idx)
c_fw_ver = create_string_buffer(EFML_MAX_CHAR_BUFF_LEN)
fn = efmlGetFunctionEntry("EfmlGetFwVersion")
ret = fn(c_idx, c_fw_ver)
efmlError(ret)
return c_fw_ver.value
[docs]def efmlGetDevTemp(idx):
"""
Get DTU/MEM temperature
parameters:
idx (int): selected device index
return:
| efmlDevThermalInfo_t:cur_dev_temp(float): DTU temperature,[1,95] celsius
| efmlDevThermalInfo_t:cur_hbm0_temp(float): MEM0 temperature,[1,95] celsius
| efmlDevThermalInfo_t:cur_hbm1_temp(float): MEM1 temperature,[1,95] celsius
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_idx = c_uint(idx)
c_ther = efmlDevThermalInfo_t()
fn = efmlGetFunctionEntry("EfmlGetDevTemp")
ret = fn(c_idx, byref(c_ther))
efmlError(ret)
return c_ther
[docs]def efmlGetDevVolt(idx):
"""
Get DTU voltage
parameters:
idx (int): selected device index
return:
| efmlDevVoltInfo_t:vdd_dtu(float): DTU voltage
| efmlDevVoltInfo_t:vdd_soc(float): soc voltage
| efmlDevVoltInfo_t:vdd_hbmqc(float): HBMQC voltage
| efmlDevVoltInfo_t:vdd_1v8(float): VDD 1V8 voltage
| efmlDevVoltInfo_t:vdd_vddp(float): VDD VDDP voltage
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_idx = c_uint(idx)
c_ther = efmlDevVoltInfo_t()
fn = efmlGetFunctionEntry("EfmlGetDevVolt")
ret = fn(c_idx, byref(c_ther))
efmlError(ret)
return c_ther
[docs]def efmlGetDevPwr(idx):
"""
Get DTU power consumption
parameters:
idx (int): selected device index
return:
| efmlDevPowerInfo_t:pwr_capability(float): DTU power capability,225 watt
| efmlDevPowerInfo_t:cur_pwr_consumption(float): DTU current power consumption,[1,225] watt
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_idx = c_uint(idx)
c_pwr = efmlDevPowerInfo_t()
fn = efmlGetFunctionEntry("EfmlGetDevPwr")
ret = fn(c_idx, byref(c_pwr))
efmlError(ret)
return c_pwr
[docs]def efmlGetDevDpmLevel(idx):
"""
Get DTU DPM(Dynamic Power Managerment) level
parameters:
idx (int): selected device index
return:
DPM level in int
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_idx = c_uint(idx)
c_dpm = c_uint()
fn = efmlGetFunctionEntry("EfmlGetDevDpmLevel")
ret = fn(c_idx, byref(c_dpm))
efmlError(ret)
return c_dpm.value
[docs]def efmlGetDevDtuUsage(idx):
"""
Get DTU usage
parameters:
idx (int): selected device index
return:
DTU usage value in float
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_idx = c_uint(idx)
c_dtu_usage = c_float()
fn = efmlGetFunctionEntry("EfmlGetDevDtuUsage")
ret = fn(c_idx, byref(c_dtu_usage))
efmlError(ret)
return c_dtu_usage.value
[docs]def efmlGetDevClk(idx):
"""
Get DTU/Mem clock frequency
parameters:
idx (int): selected device index
return:
efmlDevClkInfo_t:cur_hbm_clock (int): memory clock frequency
efmlDevClkInfo_t:cur_dtu_clock (int): DTU clock frequency
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_idx = c_uint(idx)
c_clk = efmlDevClkInfo_t()
fn = efmlGetFunctionEntry("EfmlGetDevClk")
ret = fn(c_idx, byref(c_clk))
efmlError(ret)
return c_clk
[docs]def efmlDumpDevList():
"""
Dump device list in system
parameters:
None
return:
None
error:
EFML_ERROR_UNINITIALIZED: library not initialized
"""
fn = efmlGetFunctionEntry("EfmlDumpDevList")
ret = fn()
efmlError(ret)
[docs]def efmlGetDevInfo(idx):
"""
Get detailed DTU information
parameters:
idx (int): selected device index
return:
| efmlDeviceInfo_t:name (char []): device name
| efmlDeviceInfo_t:vendor_id (c_uint): PCIe Vendor ID
| efmlDeviceInfo_t:device_id (c_uint): PCIe Device ID
| efmlDeviceInfo_t:domain_id (c_uint): PCIe Domain ID
| efmlDeviceInfo_t:bus_id (c_uint): PCIe Bus number
| efmlDeviceInfo_t:dev_id (c_uint): PCIe Device number
| efmlDeviceInfo_t:func_id (c_uint): PCIe Function number
| efmlDeviceInfo_t:logic_id (c_uint): device logic id
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_idx = c_uint(idx)
c_dev_info = efmlDeviceInfo_t()
fn = efmlGetFunctionEntry("EfmlGetDevInfo")
ret = fn(c_idx, byref(c_dev_info))
efmlError(ret)
return c_dev_info
## memory info
[docs]def efmlGetDevMem(idx):
"""
Get device memory information
parameters:
idx (int): selected device index
return:
| efmlDevMemInfo_t:mem_total_size (c_uint): memory size
| efmlDevMemInfo_t:mem_used (c_uint): memory usage
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_idx = c_uint(idx)
c_mem_info = efmlDevMemInfo_t()
fn = efmlGetFunctionEntry("EfmlGetDevMem")
ret = fn(c_idx, byref(c_mem_info))
efmlError(ret)
return c_mem_info
## cluster memory info
[docs]def efmlGetClusterMem(idx, cluster_idx):
"""
Get device memory information
parameters:
idx (int): selected device index
cluster_idx (int): selected cluster index
return:
| efmlClusterHbmMemInfo_t:mem_total_size (c_uint): memory size
| efmlClusterHbmMemInfo_t:mem_used (c_uint): memory usage
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_idx = c_uint(idx)
c_cluster_idx = c_uint(cluster_idx)
c_mem_info = efmlClusterHbmMemInfo_t()
fn = efmlGetFunctionEntry("EfmlGetClusterMem")
ret = fn(c_idx, c_cluster_idx, byref(c_mem_info))
efmlError(ret)
return c_mem_info
[docs]def efmlGetEccStatus(idx):
"""
Get device memory ECC status
parameters:
idx (int): selected device index
return:
ECC enablement status in int
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_idx = c_uint(idx)
c_ecc = c_uint()
fn = efmlGetFunctionEntry("EfmlGetEccStatus")
ret = fn(c_idx, byref(c_ecc))
efmlError(ret)
return c_ecc.value
## PCIe
[docs]def efmlGetPcieLinkSpeed(idx):
"""
Get device PCIe link speed
parameters:
idx (int): selected device index
return:
link speed info in efmlPcieSpeed_t
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_dev_idx = c_uint(idx)
c_link_speed = efmlLinkSpeed_t(idx)
fn = efmlGetFunctionEntry("EfmlGetPcieLinkSpeed")
ret = fn(c_dev_idx, byref(c_link_speed))
efmlError(ret)
return c_link_speed.value
[docs]def efmlGetPcieLinkWidth(idx):
"""
Get device PCIe link width
parameters:
idx (int): selected device index
return:
link width info in efmlPcieWidth_t
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_dev_idx = c_uint(idx)
c_link_width = efmlLinkWidth_t(idx)
fn = efmlGetFunctionEntry("EfmlGetPcieLinkWidth")
ret = fn(c_dev_idx, byref(c_link_width))
efmlError(ret)
return c_link_width.value
[docs]def efmlGetPcieLinkInfo(idx):
"""
Get device PCIe link information
parameters:
idx (int): selected device index
return:
| efmlPcieLinkInfo_t:link_speed : PCIe link speed
| efmlPcieLinkInfo_t:max_link_speed : PCIe supported max link speed
| efmlPcieLinkInfo_t:link_width : PCIe link width
| efmlPcieLinkInfo_t:max_link_width : PCIe supported max link width
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_dev_idx = c_uint(idx)
c_link_info = efmlPcieLinkInfo_t(0, 0, 0, 0)
fn = efmlGetFunctionEntry("EfmlGetPcieLinkInfo")
ret = fn(c_dev_idx, byref(c_link_info))
efmlError(ret)
return c_link_info
[docs]def efmlGetPcieThroughput(idx):
"""
Get device PCIe link throughput info. It will collect information in 10ms
parameters:
idx (int): selected device index
return:
| efmlPcieThroughputInfo_t:tx_throughput(float) : PCIe link Tx throughput
| efmlPcieThroughputInfo_t:rx_throughput(float) : PCIe link Rx throughput
| efmlPcieThroughputInfo_t:tx_nak(uint64) : PCIe link Tx NAK counts
| efmlPcieThroughputInfo_t:rx_nak(uint64) : PCIe link Rx NAK counts
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_dev_idx = c_uint(idx)
c_throughtput = efmlPcieThroughputInfo_t()
fn = efmlGetFunctionEntry("EfmlGetPcieThroughput")
ret = fn(c_dev_idx, byref(c_throughtput))
efmlError(ret)
return c_throughtput
## ESL
[docs]def efmlGetEslPortNum(idx):
"""
Get device ESL port number
parameters:
idx (int): selected device index
return:
ESL port number in int
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_dev_idx = c_uint(idx)
c_port_num = c_uint()
fn = efmlGetFunctionEntry("EfmlGetEslPortNum")
ret = fn(c_dev_idx, byref(c_port_num))
efmlError(ret)
return c_port_num.value
[docs]def efmlGetEslPortInfo(idx, port_id):
"""
Get device ESL port info
parameters:
| idx (int): selected device index
| port_id (int): selected ESL port ID
return:
| efmlEslPortInfo_t:connected(c_uint) : port connected status
| efmlEslPortInfo_t:vendor_id(char [16]) : port vendor id
| efmlEslPortInfo_t:device_id(c_uint) : port device id
| efmlEslPortInfo_t:domain_id(c_uint) : port domain id
| efmlEslPortInfo_t:bus_id(char [16]) : port bus id
| efmlEslPortInfo_t:dev_id(c_uint) : port device id
| efmlEslPortInfo_t:func_id(c_uint) : port function id
| efmlEslPortInfo_t:port_id(c_uint) : port id
| efmlEslPortInfo_t:port_type(efmlEslPortType_t) : port type
| efmlEslPortInfo_t:remote_card_id(c_uint) : remote port card id
| efmlEslPortInfo_t:remote_vendor_id(char [16]) :remote port vendor id
| efmlEslPortInfo_t:remote_device_id(c_uint) :remote port device id
| efmlEslPortInfo_t:remote_domain_id(c_uint) :remote port domain id
| efmlEslPortInfo_t:remote_bus_id(char [16]) :remote port bus id
| efmlEslPortInfo_t:remote_dev_id(c_uint) :remote port device id
| efmlEslPortInfo_t:remote_func_id(c_uint) :remote port function id
| efmlEslPortInfo_t:remote_port_id(c_uint) :remote port id
| efmlEslPortInfo_t:remote_port_type(efmlEslPortType_t) :remote port type
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_dev_idx = c_uint(idx)
c_port_id = c_uint(port_id)
c_port_info = efmlEslPortInfo_t()
fn = efmlGetFunctionEntry("EfmlGetEslPortInfo")
ret = fn(c_dev_idx, c_port_id, byref(c_port_info))
efmlError(ret)
return c_port_info
[docs]def efmlGetEslLinkInfo(idx, port_id):
"""
Get device ESL port link info
parameters:
| idx (int): selected device index
| port_id (int): selected ESL port ID
return:
| efmlEslLinkInfo_t:link_speed(efmlEslSpeed_t) : port link speed
| efmlEslLinkInfo_t:max_link_speed(efmlEslSpeed_t) : port max supported link speed
| efmlEslLinkInfo_t:link_width(efmlEslWidth_t) : port link width
| efmlEslLinkInfo_t:max_link_width(efmlEslWidth_t) : port max supported link width
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_dev_idx = c_uint(idx)
c_port_id = c_uint(port_id)
c_link_info = efmlEslLinkInfo_t()
fn = efmlGetFunctionEntry("EfmlGetEslLinkInfo")
ret = fn(c_dev_idx, c_port_id, byref(c_link_info))
efmlError(ret)
return c_link_info
[docs]def efmlGetEslThroughput(idx, port_id):
"""
Get device ESL port throughput info
parameters:
| idx (int): selected device index
| port_id (int): selected ESL port ID
return:
| efmlEslThroughputInfo_t:tx_throughput(float) : port tx throughput
| efmlEslThroughputInfo_t:rx_throughput(float) : port rx throughput
| efmlEslThroughputInfo_t:tx_nak(uint64) : port tx total NAK counts
| efmlEslThroughputInfo_t:rx_nak(uint64) : port rx total NAK counts
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
| EFML_ERROR_ESL_PORT_NUMBER_ERR: ESL port number error
"""
c_dev_idx = c_uint(idx)
c_port_id = c_uint(port_id)
c_throughput = efmlEslThroughputInfo_t()
fn = efmlGetFunctionEntry("EfmlGetEslThroughput")
ret = fn(c_dev_idx, c_port_id, byref(c_throughput))
efmlError(ret)
return c_throughput
[docs]def efmlGetDevClusterCount(idx):
"""
Get total DTU device cluster numbers in the dtu
parameters:
| idx (int): selected device index
return:
total device cluster numbers
error:
EFML_ERROR_UNINITIALIZED: library not initialized
"""
cnt = c_uint()
c_dev_idx = c_uint(idx)
fn = efmlGetFunctionEntry("EfmlGetClusterCount")
ret = fn(c_dev_idx, byref(cnt))
efmlError(ret)
return cnt.value
[docs]def efmlGetDevClusterUsage(idx, cluster_idx):
"""
Get DTU usage
parameters:
idx (int): selected device index
return:
DTU usage value in float
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_dev_idx = c_uint(idx)
c_cluster_idx = c_uint(cluster_idx)
c_cluster_usage = c_float()
fn = efmlGetFunctionEntry("EfmlGetDevClusterUsage")
ret = fn(c_dev_idx, c_cluster_idx, byref(c_cluster_usage))
efmlError(ret)
return c_cluster_usage.value
[docs]def efmlGetDevHealth(idx):
"""
Get DTU usage
parameters:
idx (int): selected device index
return:
DTU usage value in float
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_dev_idx = c_uint(idx)
c_dev_health = c_bool()
fn = efmlGetFunctionEntry("EfmlGetDevHealth")
ret = fn(c_dev_idx, byref(c_dev_health))
efmlError(ret)
return c_dev_health.value
## vGCU numbers per GCU
[docs]def efmlGetVdevCount(idx):
"""
Get virtual GCU numbers in the GCU.
parameters:
idx (int): selected device index
return:
total virtual GCU per GCU.
error:
EFML_ERROR_UNINITIALIZED: library not initialized
"""
cnt = c_uint()
c_dev_idx = c_uint(idx)
fn = efmlGetFunctionEntry("EfmlGetVdevCount")
ret = fn(c_dev_idx, byref(cnt))
efmlError(ret)
return cnt.value
## vGCU memory info
[docs]def efmlGetVdevDtuMem(idx, vdev_idx):
"""
Get vGCU mem info.
parameters:
idx (int): selected device index
vdev_idx (int): selected vGCU index
return:
| efmlDevMemInfo_t:mem_total_size (c_uint): memory size
| efmlDevMemInfo_t:mem_used (c_uint): memory usage
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_dev_idx = c_uint(idx)
c_vdev_idx = c_uint(vdev_idx)
c_vdev_mem_info = efmlDevMemInfo_t()
fn = efmlGetFunctionEntry("EfmlGetVdevMem")
ret = fn(c_dev_idx, c_vdev_idx, byref(c_vdev_mem_info))
efmlError(ret)
return c_vdev_mem_info
## vGCU usage info
[docs]def efmlGetVdevDtuUsage(idx, vdev_idx):
"""
Get vGCU usage
parameters:
idx (int): selected device index
vdev_idx (int): selected vGCU index
return:
vGCU usage value in float
error:
| EFML_ERROR_UNINITIALIZED: library not initialized
| EFML_ERROR_INVALID_ARGUMENT: invalid input parameters
"""
c_dev_idx = c_uint(idx)
c_vdev_idx = c_uint(vdev_idx)
c_vdev_usage = c_float()
fn = efmlGetFunctionEntry("EfmlGetVdevDtuUsage")
ret = fn(c_dev_idx, c_vdev_idx, byref(c_vdev_usage))
efmlError(ret)
return c_vdev_usage.value