|
19 | 19 |
|
20 | 20 | from .api.innolight.fr_800g import CmisFr800gApi
|
21 | 21 |
|
| 22 | +from .api.amphenol.backplane import AmphBackplaneImpl |
| 23 | +from .mem_maps.amphenol.backplane import AmphBackplaneMemMap |
| 24 | +from .codes.amphenol.backplane import AmphBackplaneCodes |
| 25 | + |
22 | 26 | from .codes.public.sff8436 import Sff8436Codes
|
23 | 27 | from .api.public.sff8436 import Sff8436Api
|
24 | 28 | from .mem_maps.public.sff8436 import Sff8436MemMap
|
@@ -70,60 +74,59 @@ def _get_vendor_part_num(self):
|
70 | 74 | return None
|
71 | 75 | vendor_pn = part_num.decode()
|
72 | 76 | return vendor_pn.strip()
|
73 |
| - |
74 |
| - def create_xcvr_api(self): |
75 |
| - # TODO: load correct classes from id_mapping file |
76 |
| - id = self._get_id() |
77 |
| - # QSFP-DD or OSFP |
78 |
| - if id == 0x18 or id == 0x19 or id == 0x1e: |
79 |
| - vendor_name = self._get_vendor_name() |
80 |
| - vendor_pn = self._get_vendor_part_num() |
81 |
| - if vendor_name == 'Credo' and vendor_pn in CREDO_800G_AEC_VENDOR_PN_LIST: |
82 |
| - codes = CmisAec800gCodes |
83 |
| - mem_map = CmisAec800gMemMap(CmisAec800gCodes) |
84 |
| - xcvr_eeprom = XcvrEeprom(self.reader, self.writer, mem_map) |
85 |
| - api = CmisAec800gApi(xcvr_eeprom) |
86 |
| - elif ('INNOLIGHT' in vendor_name and vendor_pn in INL_800G_VENDOR_PN_LIST) or \ |
87 |
| - ('EOPTOLINK' in vendor_name and vendor_pn in EOP_800G_VENDOR_PN_LIST): |
88 |
| - codes = CmisCodes |
89 |
| - mem_map = CmisMemMap(codes) |
90 |
| - xcvr_eeprom = XcvrEeprom(self.reader, self.writer, mem_map) |
91 |
| - api = CmisFr800gApi(xcvr_eeprom) |
92 |
| - else: |
93 |
| - codes = CmisCodes |
94 |
| - mem_map = CmisMemMap(codes) |
95 |
| - xcvr_eeprom = XcvrEeprom(self.reader, self.writer, mem_map) |
96 |
| - api = CmisApi(xcvr_eeprom) |
97 | 77 |
|
98 |
| - if api.is_coherent_module(): |
99 |
| - mem_map = CCmisMemMap(codes) |
100 |
| - xcvr_eeprom = XcvrEeprom(self.reader, self.writer, mem_map) |
101 |
| - api = CCmisApi(xcvr_eeprom) |
102 |
| - |
103 |
| - # QSFP28 |
104 |
| - elif id == 0x11: |
105 |
| - codes = Sff8636Codes |
106 |
| - mem_map = Sff8636MemMap(codes) |
107 |
| - xcvr_eeprom = XcvrEeprom(self.reader, self.writer, mem_map) |
108 |
| - api = Sff8636Api(xcvr_eeprom) |
109 |
| - # QSFP+ |
110 |
| - elif id == 0x0D: |
111 |
| - revision_compliance = self._get_revision_compliance() |
112 |
| - if revision_compliance >= 3: |
113 |
| - codes = Sff8636Codes |
114 |
| - mem_map = Sff8636MemMap(codes) |
115 |
| - xcvr_eeprom = XcvrEeprom(self.reader, self.writer, mem_map) |
116 |
| - api = Sff8636Api(xcvr_eeprom) |
117 |
| - else: |
118 |
| - codes = Sff8436Codes |
119 |
| - mem_map = Sff8436MemMap(codes) |
120 |
| - xcvr_eeprom = XcvrEeprom(self.reader, self.writer, mem_map) |
121 |
| - api = Sff8436Api(xcvr_eeprom) |
122 |
| - elif id == 0x03: |
123 |
| - codes = Sff8472Codes |
124 |
| - mem_map = Sff8472MemMap(codes) |
125 |
| - xcvr_eeprom = XcvrEeprom(self.reader, self.writer, mem_map) |
126 |
| - api = Sff8472Api(xcvr_eeprom) |
| 78 | + def _create_cmis_api(self): |
| 79 | + api = None |
| 80 | + vendor_name = self._get_vendor_name() |
| 81 | + vendor_pn = self._get_vendor_part_num() |
| 82 | + |
| 83 | + if vendor_name == 'Credo' and vendor_pn in CREDO_800G_AEC_VENDOR_PN_LIST: |
| 84 | + api = self._create_api(CmisAec800gCodes, CmisAec800gMemMap, CmisAec800gApi) |
| 85 | + elif ('INNOLIGHT' in vendor_name and vendor_pn in INL_800G_VENDOR_PN_LIST) or \ |
| 86 | + ('EOPTOLINK' in vendor_name and vendor_pn in EOP_800G_VENDOR_PN_LIST): |
| 87 | + api = self._create_api(CmisCodes, CmisMemMap, CmisFr800gApi) |
| 88 | + |
127 | 89 | else:
|
128 |
| - api = None |
| 90 | + api = self._create_api(CmisCodes, CmisMemMap, CmisApi) |
| 91 | + if api.is_coherent_module(): |
| 92 | + api = self._create_api(CmisCodes, CCmisMemMap, CCmisApi) |
129 | 93 | return api
|
| 94 | + |
| 95 | + def _create_qsfp_api(self): |
| 96 | + """ |
| 97 | + QSFP/QSFP+ API implementation |
| 98 | + """ |
| 99 | + revision_compliance = self._get_revision_compliance() |
| 100 | + if revision_compliance >= 3: |
| 101 | + return self._create_api(Sff8636Codes, Sff8636MemMap, Sff8636Api) |
| 102 | + else: |
| 103 | + return self._create_api(Sff8436Codes, Sff8436MemMap, Sff8436Api) |
| 104 | + |
| 105 | + def _create_api(self, codes_class, mem_map_class, api_class): |
| 106 | + codes = codes_class |
| 107 | + mem_map = mem_map_class(codes) |
| 108 | + xcvr_eeprom = XcvrEeprom(self.reader, self.writer, mem_map) |
| 109 | + return api_class(xcvr_eeprom) |
| 110 | + |
| 111 | + def create_xcvr_api(self): |
| 112 | + id = self._get_id() |
| 113 | + |
| 114 | + # Instantiate various Optics implementation based upon their respective ID as per SFF8024 |
| 115 | + id_mapping = { |
| 116 | + 0x03: (self._create_api, (Sff8472Codes, Sff8472MemMap, Sff8472Api)), |
| 117 | + 0x0D: (self._create_qsfp_api, ()), |
| 118 | + 0x11: (self._create_api, (Sff8636Codes, Sff8636MemMap, Sff8636Api)), |
| 119 | + 0x18: (self._create_cmis_api, ()), |
| 120 | + 0x19: (self._create_cmis_api, ()), |
| 121 | + 0x1b: (self._create_cmis_api, ()), |
| 122 | + 0x1e: (self._create_cmis_api, ()), |
| 123 | + 0x7e: (self._create_api, (AmphBackplaneCodes, |
| 124 | + AmphBackplaneMemMap, AmphBackplaneImpl)), |
| 125 | + } |
| 126 | + |
| 127 | + # Check if the ID exists in the mapping |
| 128 | + if id in id_mapping: |
| 129 | + func, args = id_mapping[id] |
| 130 | + if isinstance(args, tuple): |
| 131 | + return func(*args) |
| 132 | + return None |
0 commit comments