QSFP-DD and OSFP modules use CMIS, which the SFF decoders do not understand. Decode the CMIS lower memory and page 00h in the transceiver library: identifier, revision, module state, monitors, vendor data and power.
Lane monitors and page 01h are left out. They are not in this 256-byte image, and ethdev cannot report the CMIS type yet. Depends-on: series-40194 Signed-off-by: Roman Khromenok <[email protected]> --- app/test/test_transceiver.c | 117 ++++++- doc/guides/prog_guide/transceiver_lib.rst | 12 +- doc/guides/rel_notes/release_27_03.rst | 6 + lib/transceiver/cmis.c | 361 ++++++++++++++++++++++ lib/transceiver/meson.build | 1 + lib/transceiver/rte_transceiver.h | 15 +- lib/transceiver/sff_common.c | 62 ++++ lib/transceiver/sff_common.h | 26 +- 8 files changed, 589 insertions(+), 11 deletions(-) create mode 100644 lib/transceiver/cmis.c diff --git a/app/test/test_transceiver.c b/app/test/test_transceiver.c index b7ec2b95e8..705316a675 100644 --- a/app/test/test_transceiver.c +++ b/app/test/test_transceiver.c @@ -595,6 +595,118 @@ test_module_eeprom_sfp_8472_cal_round(void) return TEST_SUCCESS; } +static void +cmis_set_checksum(uint8_t *data) +{ + unsigned int sum = 0; + unsigned int i; + + for (i = 128; i <= 221; i++) + sum += data[i]; + data[222] = sum & 0xff; +} + +/* QSFP-DD module, CMIS 5.4: lower memory then page 00h */ +static void +fill_cmis(uint8_t *data) +{ + memset(data, 0, RTE_TRANSCEIVER_CMIS_LEN); + data[0] = 0x18; /* identifier: QSFP-DD */ + data[1] = 0x54; /* CMIS revision 5.4 */ + data[3] = 0x06; /* ModuleReady */ + data[9] = 0x01; /* temperature high alarm */ + put_u16(data, 14, 0x2940); /* temperature: 41.25 C */ + put_u16(data, 16, 33205); /* voltage: 3.3205 V */ + data[39] = 2; + data[40] = 3; /* active firmware 2.3 */ + data[85] = 0x02; /* media type: SMF */ + data[86] = 0x4b; /* application 1 host interface */ + data[87] = 0x1c; /* application 1 media interface */ + data[88] = 0x81; /* 8 host lanes, 1 media lane */ + data[90] = 0xff; /* application 2 unused */ + memcpy(&data[129], "ACME ", 16); + data[145] = 0x00; + data[146] = 0x1b; + data[147] = 0x21; + memcpy(&data[148], "QDD-400G-DR4 ", 16); + memcpy(&data[164], "B ", 2); + memcpy(&data[166], "SN1234567890 ", 16); + memcpy(&data[182], "240902 ", 8); + data[200] = 0x80; /* power class 5 */ + data[201] = 48; /* 12.00 W */ + data[203] = 0x0c; /* connector: MPO */ + data[212] = 0x04; /* 1310 nm DFB laser */ + cmis_set_checksum(data); +} + +static int +test_module_eeprom_cmis(void) +{ + uint8_t data[RTE_TRANSCEIVER_CMIS_LEN]; + + fill_cmis(data); + TEST_ASSERT_SUCCESS(parse(RTE_TRANSCEIVER_CMIS, data, sizeof(data)), + "Failed to parse CMIS data"); + CHECK_FIELD("Identifier", "0x18 (QSFP-DD)"); + CHECK_FIELD("CMIS revision", "5.4"); + CHECK_FIELD("Memory model", "Paged"); + CHECK_FIELD("Module state", "ModuleReady"); + CHECK_FIELD("Module state changed", "Off"); + CHECK_FIELD("Module temperature high alarm", "On"); + CHECK_FIELD("Module temperature low alarm", "Off"); + CHECK_FIELD("Module voltage high warning", "Off"); + CHECK_FIELD("Module temperature", "41.25 degrees C / 106.25 degrees F"); + CHECK_FIELD("Module voltage", "3.3205 V"); + CHECK_FIELD("Active firmware version", "2.3"); + CHECK_NO_FIELD("Module fault cause"); + CHECK_FIELD("Media type", "0x02 (optical, SMF)"); + CHECK_FIELD("Application 1", + "host 0x4b, media 0x1c, host lanes 8, media lanes 1"); + CHECK_NO_FIELD("Application 2"); + CHECK_FIELD("Vendor name", "ACME"); + CHECK_FIELD("Vendor OUI", "00:1b:21"); + CHECK_FIELD("Vendor PN", "QDD-400G-DR4"); + CHECK_FIELD("Vendor rev", "B"); + CHECK_FIELD("Vendor SN", "SN1234567890"); + CHECK_FIELD("Date code", "2024-09-02"); + CHECK_FIELD("Module power class", "5"); + CHECK_FIELD("Maximum power", "12.00 W"); + CHECK_NO_FIELD("Cable assembly length"); + CHECK_FIELD("Connector", "0x0c (MPO Parallel Optic)"); + CHECK_FIELD("Media interface technology", "0x04 (1310 nm DFB laser)"); + CHECK_FIELD("Page 00h checksum", "OK"); + return TEST_SUCCESS; +} + +static int +test_module_eeprom_cmis_flat(void) +{ + uint8_t data[RTE_TRANSCEIVER_CMIS_LEN]; + + fill_cmis(data); + data[0] = 0x1e; /* QSFP+ with CMIS */ + data[2] = 0x80; /* flat memory */ + data[3] = 0x0a; /* ModuleFault */ + data[39] = 0xff; + data[40] = 0xff; /* invalid firmware */ + data[41] = 1; /* TEC runaway */ + data[202] = 0xff; /* cable longer than 6300 m */ + data[203] = 0x25; /* CS optical connector */ + data[222] ^= 0xff; /* break the checksum */ + + TEST_ASSERT_SUCCESS(parse(RTE_TRANSCEIVER_CMIS, data, sizeof(data)), + "Failed to parse flat CMIS data"); + CHECK_FIELD("Identifier", "0x1e (QSFP+ with CMIS)"); + CHECK_FIELD("Memory model", "Flat"); + CHECK_FIELD("Module state", "ModuleFault"); + CHECK_FIELD("Active firmware version", "invalid"); + CHECK_FIELD("Module fault cause", "TEC runaway"); + CHECK_FIELD("Cable assembly length", "> 6300 m"); + CHECK_FIELD("Connector", "0x25 (CS optical connector)"); + CHECK_FIELD("Page 00h checksum", "invalid"); + return TEST_SUCCESS; +} + static int test_module_eeprom_invalid(void) { @@ -604,6 +716,7 @@ test_module_eeprom_invalid(void) RTE_TRANSCEIVER_SFF_8472, RTE_TRANSCEIVER_SFF_8436, RTE_TRANSCEIVER_SFF_8636, + RTE_TRANSCEIVER_CMIS, }; unsigned int i; int ret; @@ -620,7 +733,7 @@ test_module_eeprom_invalid(void) ret = parse(0, data, sizeof(data)); TEST_ASSERT_EQUAL(ret, -ENOTSUP, "Type 0: expected %d, got %d", -ENOTSUP, ret); - ret = parse(RTE_TRANSCEIVER_SFF_8436 + 1, data, sizeof(data)); + ret = parse(RTE_TRANSCEIVER_CMIS + 1, data, sizeof(data)); TEST_ASSERT_EQUAL(ret, -ENOTSUP, "Unknown type: expected %d, got %d", -ENOTSUP, ret); TEST_ASSERT_EQUAL(fields.count, 0, "Unknown type: callback called %u times", fields.count); @@ -655,6 +768,8 @@ static struct unit_test_suite module_eeprom_testsuite = { TEST_CASE(test_module_eeprom_qsfp_8636_thresholds), TEST_CASE(test_module_eeprom_qsfp_8636_signals_not_implemented), TEST_CASE(test_module_eeprom_qsfp_8636_signals), + TEST_CASE(test_module_eeprom_cmis), + TEST_CASE(test_module_eeprom_cmis_flat), TEST_CASE(test_module_eeprom_invalid), TEST_CASES_END() } diff --git a/doc/guides/prog_guide/transceiver_lib.rst b/doc/guides/prog_guide/transceiver_lib.rst index f146a0deef..5da74cb815 100644 --- a/doc/guides/prog_guide/transceiver_lib.rst +++ b/doc/guides/prog_guide/transceiver_lib.rst @@ -5,7 +5,7 @@ Transceiver Library =================== The transceiver library decodes the EEPROM of pluggable transceiver modules -(SFP, QSFP) according to the SFF specifications, +(SFP, QSFP, QSFP-DD, OSFP) according to the SFF and CMIS specifications, for example the vendor, the transceiver type and the digital diagnostics. The decoding does not depend on any device or driver, @@ -27,8 +27,9 @@ Kernel ports Supported Specifications ------------------------ -The module type is one of the ``RTE_TRANSCEIVER_SFF_*`` values, -which are the same as the ``RTE_ETH_MODULE_SFF_*`` values of ethdev. +The module type is one of the ``RTE_TRANSCEIVER_*`` values. +The SFF values are the same as the ``RTE_ETH_MODULE_SFF_*`` values of ethdev. +``RTE_TRANSCEIVER_CMIS`` is not reported by ethdev yet. ``RTE_TRANSCEIVER_SFF_8079`` SFP identification, page A0h (256 bytes). @@ -47,6 +48,11 @@ which are the same as the ``RTE_ETH_MODULE_SFF_*`` values of ethdev. The channel status flags are latched and cleared on read by the module, so they report the events since the previous read of the module. +``RTE_TRANSCEIVER_CMIS`` + CMIS modules (QSFP-DD, OSFP and others), lower memory and page 00h (256 bytes): + identifier, revision, module state, temperature, voltage, vendor data and power. + Page 01h and the banked lane pages are not decoded. + Usage ----- diff --git a/doc/guides/rel_notes/release_27_03.rst b/doc/guides/rel_notes/release_27_03.rst index 114a71f1ec..65c5e7796a 100644 --- a/doc/guides/rel_notes/release_27_03.rst +++ b/doc/guides/rel_notes/release_27_03.rst @@ -90,6 +90,12 @@ New Features Added a library for decoding module EEPROM data with ``rte_transceiver_decode()``. The SFF decoders moved from ethdev. +* **Added CMIS module EEPROM decoding.** + + The transceiver library decodes the CMIS lower memory and page 00h + (identifier, module state, monitors, vendor data and power) + for ``RTE_TRANSCEIVER_CMIS``. + Removed Items ------------- diff --git a/lib/transceiver/cmis.c b/lib/transceiver/cmis.c new file mode 100644 index 0000000000..958ba4f5f1 --- /dev/null +++ b/lib/transceiver/cmis.c @@ -0,0 +1,361 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2026 Roman Khromenok + * + * Decode the CMIS lower memory and page 00h (OIF-CMIS-05.4). + * Page 01h and the banked pages are not part of this 256-byte layout. + */ + +#include <stdbool.h> +#include <stdio.h> +#include <string.h> + +#include <rte_bitops.h> + +#include "sff_common.h" + +/* Lower memory, OIF-CMIS-05.4 Table 8-4 and Table 8-5 */ +#define CMIS_ID 0 +#define CMIS_REV 1 +#define CMIS_MGMT 2 +#define CMIS_STATE 3 +#define CMIS_FLAGS 8 +#define CMIS_MON_FLAGS 9 +#define CMIS_TEMP 14 +#define CMIS_VCC 16 +#define CMIS_FW_MAJOR 39 +#define CMIS_FW_MINOR 40 +#define CMIS_FAULT 41 +#define CMIS_MEDIA_TYPE 85 +#define CMIS_APP 86 +#define CMIS_APP_COUNT 8 +#define CMIS_APP_LEN 4 + +/* Page 00h, Table 8-27. Stored at offset 128 of the flat EEPROM image */ +#define CMIS_VENDOR_NAME 129 +#define CMIS_VENDOR_OUI 145 +#define CMIS_VENDOR_PN 148 +#define CMIS_VENDOR_REV 164 +#define CMIS_VENDOR_SN 166 +#define CMIS_DATE 182 +#define CMIS_POWER_CLASS 200 +#define CMIS_MAX_POWER 201 +#define CMIS_CABLE_LEN 202 +#define CMIS_CONNECTOR 203 +#define CMIS_MEDIA_TECH 212 +#define CMIS_CHKSUM_FIRST 128 +#define CMIS_CHKSUM_LAST 221 +#define CMIS_CHKSUM 222 + +#define CMIS_MEMORY_MODEL RTE_BIT32(7) +#define CMIS_STATE_MASK 0x0e +#define CMIS_STATE_SHIFT 1 + +static uint16_t +cmis_be16(const uint8_t *data) +{ + return (uint16_t)((data[0] << 8) | data[1]); +} + +static bool +cmis_is_zero(const uint8_t *data, unsigned int first, unsigned int last) +{ + unsigned int i; + + for (i = first; i <= last; i++) + if (data[i] != 0) + return false; + return true; +} + +static void +cmis_show_text(const uint8_t *data, unsigned int first, unsigned int last, + const char *name, struct sff_output *d) +{ + if (cmis_is_zero(data, first, last)) { + sff_output_field(d, name, "unspecified"); + return; + } + sff_show_ascii(data, first, last, name, d); +} + +static void +cmis_show_flag(const char *name, uint8_t value, uint8_t mask, + struct sff_output *d) +{ + sff_output_field(d, name, (value & mask) ? "On" : "Off"); +} + +static void +cmis_show_state(uint8_t code, struct sff_output *d) +{ + static const char * const name[] = { + "reserved", + "ModuleLowPwr", + "ModulePwrUp", + "ModuleReady", + "ModulePwrDn", + "ModuleFault", + "reserved", + "reserved", + }; + + sff_output_field(d, "Module state", name[code & 7]); +} + +static void +cmis_show_firmware(const uint8_t *data, struct sff_output *d) +{ + char value[SFF_ITEM_VAL_COMPOSE_SIZE]; + uint8_t major = data[CMIS_FW_MAJOR]; + uint8_t minor = data[CMIS_FW_MINOR]; + + if (major == 0 && minor == 0) + strlcpy(value, "none", sizeof(value)); + else if (major == 0xff && minor == 0xff) + strlcpy(value, "invalid", sizeof(value)); + else + snprintf(value, sizeof(value), "%u.%u", major, minor); + sff_output_field(d, "Active firmware version", value); +} + +static void +cmis_show_fault(uint8_t code, struct sff_output *d) +{ + static const char * const name[] = { + [1] = "TEC runaway", + [2] = "data memory corrupted", + [3] = "program memory corrupted", + [4] = "transmitter fault", + [5] = "receiver fault", + [6] = "temperature related fault", + }; + const char *text = "reserved"; + + if (code == 0) + return; + if (code < RTE_DIM(name) && name[code] != NULL) + text = name[code]; + sff_output_field(d, "Module fault cause", text); +} + +static void +cmis_show_media_type(uint8_t code, struct sff_output *d) +{ + static const char * const name[] = { + [0x00] = "undefined", + [0x01] = "optical, MMF", + [0x02] = "optical, SMF", + [0x03] = "passive or linear active copper", + [0x04] = "active cable", + [0x05] = "BASE-T", + }; + char value[SFF_ITEM_VAL_COMPOSE_SIZE]; + const char *text = "reserved"; + + if (code >= 0x40 && code <= 0x8f) + text = "custom"; + else if (code < RTE_DIM(name) && name[code] != NULL) + text = name[code]; + snprintf(value, sizeof(value), "0x%02x (%s)", code, text); + sff_output_field(d, "Media type", value); +} + +static void +cmis_show_lane_count(char *buf, size_t size, unsigned int lanes) +{ + if (lanes == 0) + strlcpy(buf, "ID", size); + else + snprintf(buf, size, "%u", lanes); +} + +static void +cmis_show_apps(const uint8_t *data, struct sff_output *d) +{ + unsigned int i; + + for (i = 0; i < CMIS_APP_COUNT; i++) { + const uint8_t *app = &data[CMIS_APP + i * CMIS_APP_LEN]; + char name[SFF_ITEM_VAL_COMPOSE_SIZE]; + char value[SFF_ITEM_VAL_COMPOSE_SIZE]; + char host_lanes[8]; + char media_lanes[8]; + + /* FFh marks an unused descriptor, Table 8-22 */ + if (app[0] == 0xff) + continue; + + cmis_show_lane_count(host_lanes, sizeof(host_lanes), app[2] >> 4); + cmis_show_lane_count(media_lanes, sizeof(media_lanes), app[2] & 0xf); + snprintf(name, sizeof(name), "Application %u", i + 1); + snprintf(value, sizeof(value), + "host 0x%02x, media 0x%02x, host lanes %s, media lanes %s", + app[0], app[1], host_lanes, media_lanes); + sff_output_field(d, name, value); + } +} + +static void +cmis_show_date(const uint8_t *data, struct sff_output *d) +{ + const uint8_t *date = &data[CMIS_DATE]; + char value[SFF_ITEM_VAL_COMPOSE_SIZE]; + unsigned int i; + + for (i = 0; i < 6; i++) { + if (date[i] < '0' || date[i] > '9') { + sff_show_ascii(data, CMIS_DATE, CMIS_DATE + 7, "Date code", d); + return; + } + } + + snprintf(value, sizeof(value), "20%c%c-%c%c-%c%c", + date[0], date[1], date[2], date[3], date[4], date[5]); + if (date[6] > ' ' && date[7] > ' ') + snprintf(value + strlen(value), sizeof(value) - strlen(value), + " %c%c", date[6], date[7]); + sff_output_field(d, "Date code", value); +} + +static void +cmis_show_power(const uint8_t *data, struct sff_output *d) +{ + char value[SFF_ITEM_VAL_COMPOSE_SIZE]; + unsigned int power_class = (data[CMIS_POWER_CLASS] >> 5) + 1; + + snprintf(value, sizeof(value), "%u", power_class); + sff_output_field(d, "Module power class", value); + snprintf(value, sizeof(value), "%.2f W", data[CMIS_MAX_POWER] * 0.25); + sff_output_field(d, "Maximum power", value); +} + +static void +cmis_show_cable_length(uint8_t code, struct sff_output *d) +{ + char value[SFF_ITEM_VAL_COMPOSE_SIZE]; + unsigned int multiplier = code >> 6; + unsigned int base = code & 0x3f; + static const unsigned int scale[] = { 1, 10, 100 }; + + /* Base length 0 means the media can be disconnected, Table 8-33 */ + if (base == 0) + return; + if (code == 0xff) { + sff_output_field(d, "Cable assembly length", "> 6300 m"); + return; + } + if (multiplier == 0) + snprintf(value, sizeof(value), "%.1f m", base / 10.0); + else + snprintf(value, sizeof(value), "%u m", base * scale[multiplier - 1]); + sff_output_field(d, "Cable assembly length", value); +} + +static void +cmis_show_media_tech(uint8_t code, struct sff_output *d) +{ + static const char * const name[] = { + [0x00] = "850 nm VCSEL", + [0x01] = "1310 nm VCSEL", + [0x02] = "1550 nm VCSEL", + [0x03] = "1310 nm FP laser", + [0x04] = "1310 nm DFB laser", + [0x05] = "1550 nm DFB laser", + [0x06] = "1310 nm EML", + [0x07] = "1550 nm EML", + [0x08] = "others", + [0x09] = "1490 nm DFB laser", + [0x0a] = "copper cable, passive, unequalized", + [0x0b] = "copper cable, passive, equalized", + [0x0c] = "copper cable with near and far end limiting active equalizers", + [0x0d] = "copper cable with far end limiting active equalizers", + [0x0e] = "copper cable with near end limiting active equalizers", + [0x0f] = "copper cable with linear active equalizers", + [0x10] = "C-band tunable laser", + [0x11] = "L-band tunable laser", + [0x12] = "copper cable with near and far end linear active equalizers", + [0x13] = "copper cable with far end linear active equalizers", + [0x14] = "copper cable with near end linear active equalizers", + }; + char value[96]; + const char *text = "reserved"; + + if (code < RTE_DIM(name) && name[code] != NULL) + text = name[code]; + snprintf(value, sizeof(value), "0x%02x (%s)", code, text); + sff_output_field(d, "Media interface technology", value); +} + +static void +cmis_show_checksum(const uint8_t *data, struct sff_output *d) +{ + unsigned int sum = 0; + unsigned int i; + + for (i = CMIS_CHKSUM_FIRST; i <= CMIS_CHKSUM_LAST; i++) + sum += data[i]; + sff_output_field(d, "Page 00h checksum", + ((sum & 0xff) == data[CMIS_CHKSUM]) ? "OK" : "invalid"); +} + +void +cmis_show_all(const uint8_t *data, struct sff_output *d) +{ + char value[SFF_ITEM_VAL_COMPOSE_SIZE]; + + sff_8024_show_identifier(data, CMIS_ID, d); + snprintf(value, sizeof(value), "%u.%u", + data[CMIS_REV] >> 4, data[CMIS_REV] & 0xf); + sff_output_field(d, "CMIS revision", value); + sff_output_field(d, "Memory model", + (data[CMIS_MGMT] & CMIS_MEMORY_MODEL) ? "Flat" : "Paged"); + cmis_show_state(data[CMIS_STATE] >> CMIS_STATE_SHIFT, d); + + cmis_show_flag("Module state changed", data[CMIS_FLAGS], RTE_BIT32(0), d); + cmis_show_flag("Module firmware error", data[CMIS_FLAGS], RTE_BIT32(1), d); + cmis_show_flag("Data path firmware error", data[CMIS_FLAGS], RTE_BIT32(2), d); + cmis_show_flag("Abnormal firmware indication", data[CMIS_FLAGS], + RTE_BIT32(3), d); + + cmis_show_flag("Module temperature high alarm", data[CMIS_MON_FLAGS], + RTE_BIT32(0), d); + cmis_show_flag("Module temperature low alarm", data[CMIS_MON_FLAGS], + RTE_BIT32(1), d); + cmis_show_flag("Module temperature high warning", data[CMIS_MON_FLAGS], + RTE_BIT32(2), d); + cmis_show_flag("Module temperature low warning", data[CMIS_MON_FLAGS], + RTE_BIT32(3), d); + cmis_show_flag("Module voltage high alarm", data[CMIS_MON_FLAGS], + RTE_BIT32(4), d); + cmis_show_flag("Module voltage low alarm", data[CMIS_MON_FLAGS], + RTE_BIT32(5), d); + cmis_show_flag("Module voltage high warning", data[CMIS_MON_FLAGS], + RTE_BIT32(6), d); + cmis_show_flag("Module voltage low warning", data[CMIS_MON_FLAGS], + RTE_BIT32(7), d); + + SFF_SPRINT_TEMP(value, (int16_t)cmis_be16(&data[CMIS_TEMP])); + sff_output_field(d, "Module temperature", value); + SFF_SPRINT_VCC(value, cmis_be16(&data[CMIS_VCC])); + sff_output_field(d, "Module voltage", value); + + cmis_show_firmware(data, d); + cmis_show_fault(data[CMIS_FAULT], d); + cmis_show_media_type(data[CMIS_MEDIA_TYPE], d); + cmis_show_apps(data, d); + + cmis_show_text(data, CMIS_VENDOR_NAME, CMIS_VENDOR_NAME + 15, "Vendor name", d); + if (cmis_is_zero(data, CMIS_VENDOR_OUI, CMIS_VENDOR_OUI + 2)) + sff_output_field(d, "Vendor OUI", "unspecified"); + else + sff_8024_show_oui(data, CMIS_VENDOR_OUI, d); + cmis_show_text(data, CMIS_VENDOR_PN, CMIS_VENDOR_PN + 15, "Vendor PN", d); + cmis_show_text(data, CMIS_VENDOR_REV, CMIS_VENDOR_REV + 1, "Vendor rev", d); + cmis_show_text(data, CMIS_VENDOR_SN, CMIS_VENDOR_SN + 15, "Vendor SN", d); + cmis_show_date(data, d); + cmis_show_power(data, d); + cmis_show_cable_length(data[CMIS_CABLE_LEN], d); + sff_8024_show_connector(data, CMIS_CONNECTOR, d); + cmis_show_media_tech(data[CMIS_MEDIA_TECH], d); + cmis_show_checksum(data, d); +} diff --git a/lib/transceiver/meson.build b/lib/transceiver/meson.build index 895f117909..c1c0cceff4 100644 --- a/lib/transceiver/meson.build +++ b/lib/transceiver/meson.build @@ -2,6 +2,7 @@ # Copyright(c) 2026 Roman Khromenok sources = files( + 'cmis.c', 'rte_transceiver.c', 'sff_8079.c', 'sff_8472.c', diff --git a/lib/transceiver/rte_transceiver.h b/lib/transceiver/rte_transceiver.h index cc112f3913..cf404a6dfa 100644 --- a/lib/transceiver/rte_transceiver.h +++ b/lib/transceiver/rte_transceiver.h @@ -10,8 +10,8 @@ * * Pluggable transceiver module EEPROM decoding. * - * Decode the EEPROM of pluggable transceiver modules (SFP, QSFP) - * according to the SFF specifications. + * Decode the EEPROM of pluggable transceiver modules (SFP, QSFP, QSFP-DD, OSFP) + * according to the SFF and CMIS specifications. * The decoding does not depend on any device or driver: * the EEPROM data may be read with rte_eth_dev_get_module_eeprom() * or from any other source using the same layout, @@ -29,8 +29,9 @@ extern "C" { /* * Module EEPROM layouts. - * The values are the same as the RTE_ETH_MODULE_SFF_* values + * The SFF values are the same as the RTE_ETH_MODULE_SFF_* values * reported by rte_eth_dev_get_module_info(). + * RTE_TRANSCEIVER_CMIS is not reported by ethdev yet. */ #define RTE_TRANSCEIVER_SFF_8079 0x1 /**< SFF-8079 (SFP), page A0h */ #define RTE_TRANSCEIVER_SFF_8079_LEN 256 /**< SFF-8079 EEPROM length */ @@ -42,6 +43,8 @@ extern "C" { #define RTE_TRANSCEIVER_SFF_8436 0x4 /**< SFF-8436 (QSFP+) */ #define RTE_TRANSCEIVER_SFF_8436_LEN 256 /**< SFF-8436 lower and page 00h length */ #define RTE_TRANSCEIVER_SFF_8436_MAX_LEN 640 /**< SFF-8436 length with page 03h */ +#define RTE_TRANSCEIVER_CMIS 0x5 /**< CMIS, lower memory and page 00h */ +#define RTE_TRANSCEIVER_CMIS_LEN 256 /**< CMIS lower memory and page 00h length */ /** * Callback invoked by rte_transceiver_decode() for each decoded field. @@ -66,13 +69,13 @@ typedef void (*rte_transceiver_field_cb)(const char *name, const char *value, * @warning * @b EXPERIMENTAL: this API may change without prior notice. * - * Decode pluggable module EEPROM data according to the SFF specifications. + * Decode pluggable module EEPROM data according to the SFF and CMIS specifications. * * The function does not access any device * and can be called without EAL initialization. * * @param type - * Module EEPROM layout, one of RTE_TRANSCEIVER_SFF_*. + * Module EEPROM layout, one of RTE_TRANSCEIVER_SFF_* or RTE_TRANSCEIVER_CMIS. * @param data * Module EEPROM data starting at offset 0. * @param length @@ -81,6 +84,8 @@ typedef void (*rte_transceiver_field_cb)(const char *name, const char *value, * RTE_TRANSCEIVER_SFF_8472_LEN bytes are provided. * SFF-8436 and SFF-8636 thresholds and alarm flags are decoded * only if at least RTE_TRANSCEIVER_SFF_8636_MAX_LEN bytes are provided. + * CMIS decoding requires RTE_TRANSCEIVER_CMIS_LEN bytes + * and covers the lower memory and page 00h. * @param cb * Callback invoked for each decoded field. * @param arg diff --git a/lib/transceiver/sff_common.c b/lib/transceiver/sff_common.c index 321fe63e05..d969f8d4ac 100644 --- a/lib/transceiver/sff_common.c +++ b/lib/transceiver/sff_common.c @@ -38,6 +38,11 @@ int sff_decode_module_eeprom(uint32_t type, const uint8_t *data, uint32_t length return -EINVAL; sff_8636_show_all(data, length, d); break; + case RTE_TRANSCEIVER_CMIS: + if (length < RTE_TRANSCEIVER_CMIS_LEN) + return -EINVAL; + cmis_show_all(data, d); + break; default: return -ENOTSUP; } @@ -200,6 +205,51 @@ void sff_8024_show_identifier(const uint8_t *data, int id_offset, struct sff_out case SFF_8024_ID_MICRO_QSFP: strlcat(val_string, " (microQSFP)", sizeof(val_string)); break; + case SFF_8024_ID_QSFP_DD: + strlcat(val_string, " (QSFP-DD)", sizeof(val_string)); + break; + case SFF_8024_ID_OSFP: + strlcat(val_string, " (OSFP)", sizeof(val_string)); + break; + case SFF_8024_ID_SFP_DD: + strlcat(val_string, " (SFP-DD)", sizeof(val_string)); + break; + case SFF_8024_ID_DSFP: + strlcat(val_string, " (DSFP)", sizeof(val_string)); + break; + case SFF_8024_ID_MINILINK_4X: + strlcat(val_string, " (x4 MiniLink/OcuLink)", sizeof(val_string)); + break; + case SFF_8024_ID_MINILINK_8X: + strlcat(val_string, " (x8 MiniLink)", sizeof(val_string)); + break; + case SFF_8024_ID_QSFP_CMIS: + strlcat(val_string, " (QSFP+ with CMIS)", sizeof(val_string)); + break; + case SFF_8024_ID_SFP_DD_CMIS: + strlcat(val_string, " (SFP-DD with CMIS)", sizeof(val_string)); + break; + case SFF_8024_ID_SFP_CMIS: + strlcat(val_string, " (SFP+ with CMIS)", sizeof(val_string)); + break; + case SFF_8024_ID_OSFP_XD: + strlcat(val_string, " (OSFP-XD)", sizeof(val_string)); + break; + case SFF_8024_ID_OIF_ELSFP: + strlcat(val_string, " (OIF-ELSFP)", sizeof(val_string)); + break; + case SFF_8024_ID_CDFP_X4_PCIE: + strlcat(val_string, " (CDFP x4 PCIe)", sizeof(val_string)); + break; + case SFF_8024_ID_CDFP_X8_PCIE: + strlcat(val_string, " (CDFP x8 PCIe)", sizeof(val_string)); + break; + case SFF_8024_ID_CDFP_X16_PCIE: + strlcat(val_string, " (CDFP x16 PCIe)", sizeof(val_string)); + break; + case SFF_8024_ID_XPO: + strlcat(val_string, " (XPO)", sizeof(val_string)); + break; default: strlcat(val_string, " (reserved or unknown)", sizeof(val_string)); break; @@ -271,6 +321,18 @@ void sff_8024_show_connector(const uint8_t *data, int ctor_offset, struct sff_ou case SFF_8024_CTOR_MXC_2x16: strlcat(val_string, " (MXC 2x16)", sizeof(val_string)); break; + case SFF_8024_CTOR_CS: + strlcat(val_string, " (CS optical connector)", sizeof(val_string)); + break; + case SFF_8024_CTOR_SN: + strlcat(val_string, " (SN optical connector)", sizeof(val_string)); + break; + case SFF_8024_CTOR_MPO_2x12: + strlcat(val_string, " (MPO 2x12)", sizeof(val_string)); + break; + case SFF_8024_CTOR_MPO_1x16: + strlcat(val_string, " (MPO 1x16)", sizeof(val_string)); + break; default: strlcat(val_string, " (reserved or unknown)", sizeof(val_string)); break; diff --git a/lib/transceiver/sff_common.h b/lib/transceiver/sff_common.h index 015c59d261..caf2a129b3 100644 --- a/lib/transceiver/sff_common.h +++ b/lib/transceiver/sff_common.h @@ -38,6 +38,9 @@ void sff_8472_show_all(const uint8_t *data, struct sff_output *d); /* SFF-8636 Optics diagnostics */ void sff_8636_show_all(const uint8_t *data, uint32_t eeprom_len, struct sff_output *d); +/* CMIS lower memory and page 00h */ +void cmis_show_all(const uint8_t *data, struct sff_output *d); + /* * Decode module EEPROM of the given type (RTE_TRANSCEIVER_SFF_*). * Returns 0 on success, -EINVAL if the data is too short for the type, @@ -71,7 +74,22 @@ int sff_decode_module_eeprom(uint32_t type, const uint8_t *data, uint32_t length #define SFF_8024_ID_HD8X_FANOUT 0x15 #define SFF_8024_ID_CDFP_S3 0x16 #define SFF_8024_ID_MICRO_QSFP 0x17 -#define SFF_8024_ID_LAST SFF_8024_ID_MICRO_QSFP +#define SFF_8024_ID_QSFP_DD 0x18 +#define SFF_8024_ID_OSFP 0x19 +#define SFF_8024_ID_SFP_DD 0x1A +#define SFF_8024_ID_DSFP 0x1B +#define SFF_8024_ID_MINILINK_4X 0x1C +#define SFF_8024_ID_MINILINK_8X 0x1D +#define SFF_8024_ID_QSFP_CMIS 0x1E +#define SFF_8024_ID_SFP_DD_CMIS 0x1F +#define SFF_8024_ID_SFP_CMIS 0x20 +#define SFF_8024_ID_OSFP_XD 0x21 +#define SFF_8024_ID_OIF_ELSFP 0x22 +#define SFF_8024_ID_CDFP_X4_PCIE 0x23 +#define SFF_8024_ID_CDFP_X8_PCIE 0x24 +#define SFF_8024_ID_CDFP_X16_PCIE 0x25 +#define SFF_8024_ID_XPO 0x26 +#define SFF_8024_ID_LAST SFF_8024_ID_XPO #define SFF_8024_ID_UNALLOCATED_LAST 0x7F #define SFF_8024_ID_VENDOR_START 0x80 #define SFF_8024_ID_VENDOR_LAST 0xFF @@ -96,7 +114,11 @@ int sff_decode_module_eeprom(uint32_t type, const uint8_t *data, uint32_t length #define SFF_8024_CTOR_RJ45 0x22 #define SFF_8024_CTOR_NO_SEPARABLE 0x23 #define SFF_8024_CTOR_MXC_2x16 0x24 -#define SFF_8024_CTOR_LAST SFF_8024_CTOR_MXC_2x16 +#define SFF_8024_CTOR_CS 0x25 +#define SFF_8024_CTOR_SN 0x26 +#define SFF_8024_CTOR_MPO_2x12 0x27 +#define SFF_8024_CTOR_MPO_1x16 0x28 +#define SFF_8024_CTOR_LAST SFF_8024_CTOR_MPO_1x16 #define SFF_8024_CTOR_UNALLOCATED_LAST 0x7F #define SFF_8024_CTOR_VENDOR_START 0x80 #define SFF_8024_CTOR_VENDOR_LAST 0xFF -- 2.47.3

