xref: /freebsd/lib/libifconfig/sfp.lua (revision 43a5ec4eb41567cc92586503212743d89686d78f)
1#!/usr/libexec/flua
2-- ex: sw=4 et:
3--[[
4/*-
5 * Copyright (c) 2014, Alexander V. Chernikov
6 * Copyright (c) 2020, Ryan Moeller <freqlabs@FreeBSD.org>
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * $FreeBSD$
30 */
31]]
32
33-- Try to put the template.lua library in the package search path.
34package.path = (os.getenv("SRCTOP") or "/usr/src").."/tools/lua/?.lua"
35
36-- Render the template named by the first argument to this script.
37require("template").render(arg[1], { -- This table is the template's context.
38
39-- The table `enums' is accessible in the template.  It is a list of strings
40-- and tables that describe the various enum types we are generating and the
41-- ancillary metadata for generating other related code.
42enums = {
43
44    -- Strings at this level are rendered as block comments for convenience.
45    "SFF-8024 Rev. 4.6 Table 4-1: Indentifier Values",
46
47    -- This table describes an enum type, in this case enum sfp_id:
48    {
49        name = "id", -- The template prepends the sfp_ prefix to our name.
50        description = "Transceiver identifier",
51
52        -- What width int is needed to store this type:
53        bits = 8, -- This could be inferred by the values below...
54
55        -- The values, symbols, display names, and descriptions of this enum:
56        values =  {
57            -- The prefix SFP_ID_ is prepended to the symbolic names.
58            -- Only this enum has shortened names for the values, though they
59            -- could be added to the other enums.
60
61            -- value, symbolic name, description, shortened name
62            {0x00, "UNKNOWN",   "Unknown or unspecified", "Unknown"},
63            {0x01, "GBIC",      "GBIC",               "GBIC"},
64            {0x02, "SFF",       "Module soldered to motherboard (ex: SFF)",
65                "SFF"},
66            {0x03, "SFP",       "SFP or SFP+",        "SFP/SFP+/SFP28"},
67            {0x04, "XBI",       "300 pin XBI",        "XBI"},
68            {0x05, "XENPAK",    "Xenpak",             "Xenpak"},
69            {0x06, "XFP",       "XFP",                "XFP"},
70            {0x07, "XFF",       "XFF",                "XFF"},
71            {0x08, "XFPE",      "XFP-E",              "XFP-E"},
72            {0x09, "XPAK",      "XPAK",               "XPAK"},
73            {0x0A, "X2",        "X2",                 "X2"},
74            {0x0B, "DWDM_SFP",  "DWDM-SFP/SFP+",      "DWDM-SFP/SFP+"},
75            {0x0C, "QSFP",      "QSFP",               "QSFP"},
76            {0x0D, "QSFPPLUS",  "QSFP+ or later",     "QSFP+"},
77            {0x0E, "CXP",       "CXP",                "CXP"},
78            {0x0F, "HD4X",      "Shielded Mini Multilane HD 4X", "HD4X"},
79            {0x10, "HD8X",      "Shielded Mini Multilane HD 8X", "HD8X"},
80            {0x11, "QSFP28",    "QSFP28 or later",    "QSFP28"},
81            {0x12, "CXP2",      "CXP2 (aka CXP28)",   "CXP2"},
82            {0x13, "CDFP",      "CDFP (Style 1/Style 2)", "CDFP"},
83            {0x14, "SMM4",      "Shielded Mini Multilane HD 4X fanout",
84                "SMM4"},
85            {0x15, "SMM8",      "Shielded Mini Multilane HD 8X fanout",
86                "SMM8"},
87            {0x16, "CDFP3",     "CDFP (Style 3)",     "CDFP3"},
88            {0x17, "MICROQSFP", "microQSFP",          "microQSFP"},
89            {0x18, "QSFP_DD",   "QSFP-DD 8X pluggable transceiver", "QSFP-DD"},
90            {0x19, "QSFP8X",    "QSFP 8X pluggable transceiver", "QSFP8X"},
91            {0x1A, "SFP_DD",    "SFP-DD 2X pluggable transceiver", "SFP-DD"},
92            {0x1B, "DSFP",      "DSFP Dual SFP pluggable transceiver", "DSFP"},
93            {0x1C, "X4ML",      "x4 MiniLink/OcuLink", "x4MiniLink/OcuLink"},
94            {0x1D, "X8ML",      "x8 MiniLink", "x8MiniLink"},
95            {0x1E, "QSFP_CMIS",
96                "QSFP+ or later w/Common Management Interface Specification",
97                "QSFP+(CMIS)"},
98        },
99    },
100
101    "SFF-8024 Rev. 4.6 Table 4-3: Connector Types",
102    {
103        name = "conn",
104        description = "Connector type",
105        bits = 8,
106        values = {
107            {0x00, "UNKNOWN",         "Unknown"},
108            {0x01, "SC",              "SC"},
109            {0x02, "FC_1_COPPER",     "Fibre Channel Style 1 copper"},
110            {0x03, "FC_2_COPPER",     "Fibre Channel Style 2 copper"},
111            {0x04, "BNC_TNC",         "BNC/TNC"},
112            {0x05, "FC_COAX",         "Fibre Channel coaxial"},
113            {0x06, "FIBER_JACK",      "Fiber Jack"},
114            {0x07, "LC",              "LC"},
115            {0x08, "MT_RJ",           "MT-RJ"},
116            {0x09, "MU",              "MU"},
117            {0x0A, "SG",              "SG"},
118            {0x0B, "OPTICAL_PIGTAIL", "Optical pigtail"},
119            {0x0C, "MPO_1X12_POPTIC", "MPO 1x12 Parallel Optic"},
120            {0x0D, "MPO_2X16_POPTIC", "MPO 2x16 Parallel Optic"},
121            {0x20, "HSSDC_II",        "HSSDC II"},
122            {0x21, "COPPER_PIGTAIL",  "Copper pigtail"},
123            {0x22, "RJ45",            "RJ45"},
124            {0x23, "NONE",            "No separable connector"},
125            {0x24, "MXC_2X16",        "MXC 2x16"},
126            {0x25, "CS_OPTICAL",      "CS optical connector"},
127            {0x26, "MINI_CS_OPTICAL", "Mini CS optical connector"},
128            {0x27, "MPO_2X12_POPTIC", "MPO 2x12 Parallel Optic"},
129            {0x28, "MPO_1X16_POPTIC", "MPO 1x16 Parallel Optic"},
130        },
131    },
132    "SFF-8472 Rev. 11.4 table 3.5: Transceiver codes",
133    "10G Ethernet/IB compliance codes, byte 3",
134    {
135        name = "eth_10g",
136        description = "10G Ethernet/IB compliance",
137        bits = 8,
138        values = {
139            {0x80, "10G_BASE_ER",       "10G Base-ER"},
140            {0x40, "10G_BASE_LRM",      "10G Base-LRM"},
141            {0x20, "10G_BASE_LR",       "10G Base-LR"},
142            {0x10, "10G_BASE_SR",       "10G Base-SR"},
143            {0x08, "1X_SX",             "1X SX"},
144            {0x04, "1X_LX",             "1X LX"},
145            {0x02, "1X_COPPER_ACTIVE",  "1X Copper Active"},
146            {0x01, "1X_COPPER_PASSIVE", "1X Copper Passive"},
147        },
148    },
149    "Ethernet compliance codes, byte 6",
150    {
151        name = "eth",
152        description = "Ethernet compliance",
153        bits = 8,
154        values = {
155            {0x80, "BASE_PX",         "BASE-PX"},
156            {0x40, "BASE_BX10",       "BASE-BX10"},
157            {0x20, "100BASE_FX",      "100BASE-FX"},
158            {0x10, "100BASE_LX_LX10", "100BASE-LX/LX10"},
159            {0x08, "1000BASE_T",      "1000BASE-T"},
160            {0x04, "1000BASE_CX",     "1000BASE-CX"},
161            {0x02, "1000BASE_LX",     "1000BASE-LX"},
162            {0x01, "1000BASE_SX",     "1000BASE-SX"},
163        },
164    },
165    "FC link length, byte 7",
166    {
167        name = "fc_len",
168        description = "Fibre Channel link length",
169        bits = 8,
170        values = {
171            {0x80, "VERY_LONG",    "very long distance"},
172            {0x40, "SHORT",        "short distance"},
173            {0x20, "INTERMEDIATE", "intermediate distance"},
174            {0x10, "LONG",         "long distance"},
175            {0x08, "MEDIUM",       "medium distance"},
176        },
177    },
178    "Channel/Cable technology, byte 7-8",
179    {
180        name = "cab_tech",
181        description = "Channel/cable technology",
182        bits = 16,
183        values = {
184            {0x0400, "SA",       "Shortwave laser (SA)"},
185            {0x0200, "LC",       "Longwave laser (LC)"},
186            {0x0100, "EL_INTER", "Electrical inter-enclosure (EL)"},
187            {0x0080, "EL_INTRA", "Electrical intra-enclosure (EL)"},
188            {0x0040, "SN",       "Shortwave laser (SN)"},
189            {0x0020, "SL",       "Shortwave laser (SL)"},
190            {0x0010, "LL",       "Longwave laser (LL)"},
191            {0x0008, "ACTIVE",   "Active Cable"},
192            {0x0004, "PASSIVE",  "Passive Cable"},
193        },
194    },
195    "FC Transmission media, byte 9",
196    {
197        name = "fc_media",
198        description = "Fibre Channel transmission media",
199        bits = 8,
200        values = {
201            {0x80, "TW",       "Twin Axial Pair (TW)"},
202            {0x40, "TP",       "Twisted Pair (TP)"},
203            {0x20, "MI",       "Miniature Coax (MI)"},
204            {0x10, "TV",       "Video Coax (TV)"},
205            {0x08, "M6",       "Miltimode 62.5um (M6)"},
206            {0x04, "M5",       "Multimode 50um (M5)"},
207            {0x02, "RESERVED", "Reserved"},
208            {0x01, "SM",       "Single Mode (SM)"},
209        },
210    },
211    "FC Speed, byte 10",
212    {
213        name = "fc_speed",
214        description = "Fibre Channel speed",
215        bits = 8,
216        values = {
217            {0x80, "1200", "1200 MBytes/sec"},
218            {0x40, "800",  "800 MBytes/sec"},
219            {0x20, "1600", "1600 MBytes/sec"},
220            {0x10, "400",  "400 MBytes/sec"},
221            {0x08, "3200", "3200 MBytes/sec"},
222            {0x04, "200",  "200 MBytes/sec"},
223            {0x01, "100",  "100 MBytes/sec"},
224        },
225    },
226    "SFF-8436 Rev. 4.8 table 33: Specification compliance",
227    "10/40G Ethernet compliance codes, byte 128 + 3",
228    {
229        name = "eth_1040g",
230        description = "10/40G Ethernet compliance",
231        bits = 8,
232        values = {
233            {0x80, "EXTENDED",    "Extended"},
234            {0x40, "10GBASE_LRM", "10GBASE-LRM"},
235            {0x20, "10GBASE_LR",  "10GBASE-LR"},
236            {0x10, "10GBASE_SR",  "10GBASE-SR"},
237            {0x08, "40GBASE_CR4", "40GBASE-CR4"},
238            {0x04, "40GBASE_SR4", "40GBASE-SR4"},
239            {0x02, "40GBASE_LR4", "40GBASE-LR4"},
240            {0x01, "40G_ACTIVE",  "40G Active Cable"},
241        },
242    },
243    "SFF-8024 Rev. 4.6 table 4-4: Extended Specification Compliance",
244    {
245        name = "eth_ext",
246        description = "Extended specification compliance",
247        bits = 8,
248        values = {
249            {0xFF, "RESERVED_FF",             "Reserved"},
250            {0x55, "128GFC_LW",               "128GFC LW"},
251            {0x54, "128GFC_SW",               "128GFC SW"},
252            {0x53, "128GFC_EA",               "128GFC EA"},
253            {0x52, "64GFC_LW",                "64GFC LW"},
254            {0x51, "64GFC_SW",                "64GFC SW"},
255            {0x50, "64GFC_EA",                "64GFC EA"},
256            {0x4F, "RESERVED_4F",             "Reserved"},
257            {0x4E, "RESERVED_4E",             "Reserved"},
258            {0x4D, "RESERVED_4D",             "Reserved"},
259            {0x4C, "RESERVED_4C",             "Reserved"},
260            {0x4B, "RESERVED_4B",             "Reserved"},
261            {0x4A, "RESERVED_4A",             "Reserved"},
262            {0x49, "RESERVED_49",             "Reserved"},
263            {0x48, "RESERVED_48",             "Reserved"},
264            {0x47, "RESERVED_47",             "Reserved"},
265            {0x46, "200GBASE_LR4",            "200GBASE-LR4"},
266            {0x45, "50GBASE_LR",              "50GBASE-LR"},
267            {0x44, "200G_1550NM_PSM4",        "200G 1550nm PSM4"},
268            {0x43, "200GBASE_FR4",            "200GBASE-FR4"},
269            {0x42, "50GBASE_FR_200GBASE_DR4", "50GBASE-FR or 200GBASE-DR4"},
270            {0x41, "50GBASE_SR_100GBASE_SR2_200GBASE_SR4",
271                   "50GBASE-SR/100GBASE-SR2/200GBASE-SR4"},
272            {0x40, "50GBASE_CR_100GBASE_CR2_200GBASE_CR4",
273                   "50GBASE-CR/100GBASE-CR2/200GBASE-CR4"},
274            {0x3F, "RESERVED_3F",             "Reserved"},
275            {0x3E, "RESERVED_3E",             "Reserved"},
276            {0x3D, "RESERVED_3D",             "Reserved"},
277            {0x3C, "RESERVED_3C",             "Reserved"},
278            {0x3B, "RESERVED_3B",             "Reserved"},
279            {0x3A, "RESERVED_3A",             "Reserved"},
280            {0x39, "RESERVED_39",             "Reserved"},
281            {0x38, "RESERVED_38",             "Reserved"},
282            {0x37, "RESERVED_37",             "Reserved"},
283            {0x36, "RESERVED_36",             "Reserved"},
284            {0x35, "RESERVED_35",             "Reserved"},
285            {0x34, "RESERVED_34",             "Reserved"},
286            {0x33, "50_100_200GAUI_AOC_HI_BER",
287                   "50GAUI/100GAUI-2/200GAUI-4 AOC (BER <2.6e-4)"},
288            {0x32, "50_100_200GAUI_ACC_HI_BER",
289                   "50GAUI/100GAUI-2/200GAUI-4 ACC (BER <2.6e-4)"},
290            {0x31, "50_100_200GAUI_AOC_LO_BER",
291                   "50GAUI/100GAUI-2/200GAUI-4 AOC (BER <1e-6)"},
292            {0x30, "50_100_200GAUI_ACC_LO_BER",
293                   "50GAUI/100GAUI-2/200GAUI-4 ACC (BER <1e-6)"},
294            {0x2F, "RESERVED_2F",             "Reserved"},
295            {0x2E, "RESERVED_2E",             "Reserved"},
296            {0x2D, "RESERVED_2D",             "Reserved"},
297            {0x2C, "RESERVED_2C",             "Reserved"},
298            {0x2B, "RESERVED_2B",             "Reserved"},
299            {0x2A, "RESERVED_2A",             "Reserved"},
300            {0x29, "RESERVED_29",             "Reserved"},
301            {0x28, "RESERVED_28",             "Reserved"},
302            {0x27, "100G_LR",                 "100G-LR"},
303            {0x26, "100G_FR",                 "100G-FR"},
304            {0x25, "100GBASE_DR",             "100GBASE-DR"},
305            {0x24, "4WDM_40_MSA",             "4WDM-40 MSA"},
306            {0x23, "4WDM_20_MSA",             "4WDM-20 MSA"},
307            {0x22, "4WDM_10_MSA",             "4WDM-10 MSA"},
308            {0x21, "100G_PAM4_BIDI",          "100G PAM4 BiDi"},
309            {0x20, "100G_SWDM4",              "100G SWDM4"},
310            {0x1F, "40G_SWDM4",               "40G SWDM4"},
311            {0x1E, "2_5GBASE_T",              "2.5GBASE-T"},
312            {0x1D, "5GBASE_T",                "5GBASE-T"},
313            {0x1C, "10GBASE_T_SR",            "10GBASE-T Short Reach"},
314            {0x1B, "100G_1550NM_WDM",         "100G 1550nm WDM"},
315            {0x1A, "100GE_DWDM2",             "100GE-DWDM2"},
316            {0x19, "100G_25GAUI_C2M_ACC",     "100G ACC or 25GAUI C2M ACC"},
317            {0x18, "100G_25GAUI_C2M_AOC",     "100G AOC or 25GAUI C2M AOC"},
318            {0x17, "100G_CLR4",               "100G CLR4"},
319            {0x16, "10GBASE_T_SFI",
320                   "10GBASE-T with SFI electrical interface"},
321            {0x15, "G959_1_P1L1_2D2",         "G959.1 profile P1L1-2D2"},
322            {0x14, "G959_1_P1S1_2D2",         "G959.1 profile P1S1-2D2"},
323            {0x13, "G959_1_P1I1_2D1",         "G959.1 profile P1I1-2D1"},
324            {0x12, "40G_PSM4",                "40G PSM4 Parallel SMF"},
325            {0x11, "4X_10GBASE_SR",           "4 x 10GBASE-SR"},
326            {0x10, "40GBASE_ER4",             "40GBASE-ER4"},
327            {0x0F, "RESERVED_0F",             "Reserved"},
328            {0x0E, "RESERVED_0E",             "Reserved"},
329            {0x0D, "CA_25G_N",                "25GBASE-CR CA-25G-N"},
330            {0x0C, "CA_25G_S",                "25GBASE-CR CA-25G-S"},
331            {0x0B, "CA_L",                    "100GBASE-CR4 or 25GBASE-CR CA-L"},
332            {0x0A, "RESERVED_0A",             "Reserved"},
333            {0x09, "OBSOLETE",                "Obsolete"},
334            {0x08, "100G_25GAUI_C2M_ACC_1",
335                   "100G ACC (Active Copper Cable"},
336            {0x07, "100G_PSM4_P_SMF",         "100G PSM4 Parallel SMF"},
337            {0x06, "100G_CWDM4",              "100G CWDM4"},
338            {0x05, "100GBASE_SR10",           "100GBASE-SR10"},
339            {0x04, "100GBASE_ER4_25GBASE_ER", "100GBASE-ER4 or 25GBASE-ER"},
340            {0x03, "100GBASE_LR4_25GBASE_LR", "100GBASE-LR4 or 25GBASE-LR"},
341            {0x02, "100GBASE_SR4_25GBASE_SR", "100GBASE-SR4 or 25GBASE-SR"},
342            {0x01, "100G_25GAUI_C2M_AOC_1",
343                   "100G AOC (Active Optical Cable"},
344            {0x00, "UNSPECIFIED",             "Unspecified"},
345        },
346    },
347    "SFF-8636 Rev. 2.9 table 6.3: Revision compliance",
348    {
349        name = "rev",
350        description = "Revision compliance",
351        bits = 8,
352        values = {
353            {0x1, "SFF_8436_REV_LE_4_8",     "SFF-8436 rev <=4.8"},
354            {0x2, "SFF_8436_REV_LE_4_8_ALT", "SFF-8436 rev <=4.8"},
355            {0x3, "SFF_8636_REV_LE_1_3",     "SFF-8636 rev <=1.3"},
356            {0x4, "SFF_8636_REV_LE_1_4",     "SFF-8636 rev <=1.4"},
357            {0x5, "SFF_8636_REV_LE_1_5",     "SFF-8636 rev <=1.5"},
358            {0x6, "SFF_8636_REV_LE_2_0",     "SFF-8636 rev <=2.0"},
359            {0x7, "SFF_8636_REV_LE_2_7",     "SFF-8636 rev <=2.7"},
360            {0x8, "SFF_8363_REV_GE_2_8",     "SFF-8636 rev >=2.8"},
361            {0x0, "UNSPECIFIED",             "Unspecified"},
362        },
363    },
364}
365
366-- Nothing else in this context.
367})
368