Wrap the sff module

This commit is contained in:
Carl D. Roth
2017-09-27 16:10:48 -07:00
parent db1d98dea0
commit ea2c56af00
4 changed files with 107 additions and 1 deletions

View File

@@ -4,6 +4,6 @@
#
###############################################################################
sff_AUTO_DEFS := module/auto/sff.yml
sff_AUTO_DIRS := module/inc/sff module/src
sff_AUTO_DIRS := module/inc/sff module/src module/python/onlp/sff
include $(BUILDER)/auto.mk

View File

@@ -152,6 +152,8 @@ definitions:
sff_media_type:
members: *sff_media_types
pyenum: *enums
xenum:
SFF_ENUMERATION_ENTRY:
members: *enums

View File

@@ -0,0 +1,34 @@
"""__init__.py
Module init for onlp/sff
"""
from onlp.sff.enums import *
import ctypes
sff_media_type = ctypes.c_int
sff_module_caps = ctypes.c_int
sff_module_type = ctypes.c_int
sff_sfp_type = ctypes.c_int
class sff_info(ctypes.Structure):
_fields_ = [("vendor", ctypes.c_char * 17),
("model", ctypes.c_char * 17),
("serial", ctypes.c_char * 17),
("sfp_type", sff_sfp_type),
("sfp_type_name", ctypes.c_char_p),
("module_type", sff_module_type),
("module_type_name", ctypes.c_char_p),
("media_type", sff_media_type),
("media_type_name", ctypes.c_char_p),
("caps", sff_module_caps),
("length", ctypes.c_int),
("desc", ctypes.c_char * 16),]
class sff_eeprom(ctypes.Structure):
_fields_ = [("eeprom", ctypes.c_ubyte * 256),
("cc_base", ctypes.c_ubyte),
("cc_ext", ctypes.c_ubyte),
("identified", ctypes.c_int),
("info", sff_info),]

View File

@@ -0,0 +1,70 @@
"""enums.py
Enumerations from the SFF auto.yml.
"""
class Enumeration(object):
@classmethod
def name(klass, value):
for (k, v) in klass.__dict__.iteritems():
if v == value:
return k
return None
# <auto.start.pyenum(ALL).define>
class SFF_MEDIA_TYPE(Enumeration):
COPPER = 0
FIBER = 1
class SFF_MODULE_CAPS(Enumeration):
F_100 = 1
F_1G = 2
F_10G = 4
F_25G = 8
F_40G = 16
F_100G = 32
class SFF_MODULE_TYPE(Enumeration):
_100G_AOC = 0
_100G_BASE_CR4 = 1
_100G_BASE_SR4 = 2
_100G_BASE_LR4 = 3
_100G_CWDM4 = 4
_100G_PSM4 = 5
_40G_BASE_CR4 = 6
_40G_BASE_SR4 = 7
_40G_BASE_LR4 = 8
_40G_BASE_LM4 = 9
_40G_BASE_ACTIVE = 10
_40G_BASE_CR = 11
_40G_BASE_SR2 = 12
_40G_BASE_SM4 = 13
_40G_BASE_ER4 = 14
_25G_BASE_CR = 15
_10G_BASE_SR = 16
_10G_BASE_LR = 17
_10G_BASE_LRM = 18
_10G_BASE_ER = 19
_10G_BASE_CR = 20
_10G_BASE_SX = 21
_10G_BASE_LX = 22
_10G_BASE_ZR = 23
_10G_BASE_SRL = 24
_1G_BASE_SX = 25
_1G_BASE_LX = 26
_1G_BASE_CX = 27
_1G_BASE_T = 28
_100_BASE_LX = 29
_100_BASE_FX = 30
_4X_MUX = 31
class SFF_SFP_TYPE(Enumeration):
SFP = 0
QSFP = 1
QSFP_PLUS = 2
QSFP28 = 3
# <auto.end.pyenum(ALL).define>