From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BE095A00BE; Mon, 25 Apr 2022 07:40:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B3CB94281A; Mon, 25 Apr 2022 07:39:41 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id E76EC4281A for ; Mon, 25 Apr 2022 07:39:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650865180; x=1682401180; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WLibcBCvBFA6Pk2hRH9YoY49kcpbC0zfFswZMQkgavM=; b=Jwi7PUxXXj07W5zGwJViefpOvryz9m5VcMltaREET+luu1Y+NY4TtKRl 8PSb5V6WL/SOFjPLZlg5LuJN7ZswHxGCsfoP+BMmV/ywhRcY3dzMuJMJV HI9leVkSTyUYQFeoDSML/8rTLaKJX06XUnLV0S4Inw1BAJwSzfXCFbxCL 8kiWivBAs2TupBeBn0CbdC8hl1IbD6/PBvukAXVTcR/XvzqB1289z1tt1 5rA32yHgk9usUNPBmF+jQmoIh/nXYCCU15JnIRh2OIjuB+3BZ4vTWiKtc hwUuU13DPpDw3GRZXolVSRyFaxY/SZX2luTGPs6XHTUtltA9nMg4X8qVw A==; X-IronPort-AV: E=McAfee;i="6400,9594,10327"; a="247070536" X-IronPort-AV: E=Sophos;i="5.90,287,1643702400"; d="scan'208";a="247070536" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2022 22:39:39 -0700 X-IronPort-AV: E=Sophos;i="5.90,287,1643702400"; d="scan'208";a="579087296" Received: from intel-cd-odc-robin.cd.intel.com ([10.240.178.191]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2022 22:39:36 -0700 From: Robin Zhang To: dev@dpdk.org Cc: qiming.yang@intel.com, qi.z.zhang@intel.com, stevex.yang@intel.com, thomas@monjalon.net, andrew.rybchenko@oktetlabs.ru, bruce.richardson@intel.com, david.marchand@redhat.com, Robin Zhang Subject: [PATCH v4 3/5] ethdev: format module EEPROM for SFF-8079 Date: Mon, 25 Apr 2022 05:34:44 +0000 Message-Id: <20220425053446.921528-4-robinx.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220425053446.921528-1-robinx.zhang@intel.com> References: <20220215101853.919735-1-robinx.zhang@intel.com> <20220425053446.921528-1-robinx.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch implements format module EEPROM information for SFF-8079 Rev 1.7 Signed-off-by: Robin Zhang --- lib/ethdev/ethdev_sff_telemetry.c | 3 + lib/ethdev/meson.build | 1 + lib/ethdev/sff_8079.c | 407 ++++++++++++++++++++++++++++++ 3 files changed, 411 insertions(+) create mode 100644 lib/ethdev/sff_8079.c diff --git a/lib/ethdev/ethdev_sff_telemetry.c b/lib/ethdev/ethdev_sff_telemetry.c index 507571d995..aa1e859068 100644 --- a/lib/ethdev/ethdev_sff_telemetry.c +++ b/lib/ethdev/ethdev_sff_telemetry.c @@ -64,6 +64,9 @@ sff_port_module_eeprom_display(uint16_t port_id, struct sff_item *items) switch (minfo.type) { /* parsing module EEPROM data base on different module type */ + case RTE_ETH_MODULE_SFF_8079: + sff_8079_show_all(einfo.data, items); + break; default: RTE_ETHDEV_LOG(NOTICE, "Unsupported module type: %u\n", minfo.type); break; diff --git a/lib/ethdev/meson.build b/lib/ethdev/meson.build index 8f39739e43..d94860da0c 100644 --- a/lib/ethdev/meson.build +++ b/lib/ethdev/meson.build @@ -13,6 +13,7 @@ sources = files( 'rte_tm.c', 'ethdev_sff_telemetry.c', 'sff_common.c', + 'sff_8079.c', ) headers = files( diff --git a/lib/ethdev/sff_8079.c b/lib/ethdev/sff_8079.c new file mode 100644 index 0000000000..b6736da29e --- /dev/null +++ b/lib/ethdev/sff_8079.c @@ -0,0 +1,407 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2022 Intel Corporation + * + * Implements SFF-8079 optics diagnostics. + * + */ + +#include +#include +#include +#include +#include "sff_common.h" +#include "ethdev_sff_telemetry.h" + +static void sff_8079_show_identifier(const uint8_t *data, struct sff_item *items) +{ + sff_8024_show_identifier(data, 0, items); +} + +static void sff_8079_show_ext_identifier(const uint8_t *data, struct sff_item *items) +{ + char val_string[SFF_ITEM_VAL_COMPOSE_SIZE]; + + snprintf(val_string, sizeof(val_string), "0x%02x", data[1]); + if (data[1] == 0x00) + strlcat(val_string, " (GBIC not specified / not MOD_DEF compliant)", + sizeof(val_string)); + else if (data[1] == 0x04) + strlcat(val_string, " (GBIC/SFP defined by 2-wire interface ID)", + sizeof(val_string)); + else if (data[1] <= 0x07) { + char tmp[SFF_ITEM_VAL_COMPOSE_SIZE]; + snprintf(tmp, sizeof(tmp), " (GBIC compliant with MOD_DEF %u)", data[1]); + strlcat(val_string, tmp, sizeof(val_string)); + } else + strlcat(val_string, " (unknown)", sizeof(val_string)); + add_item_string(items, "Extended identifier", val_string); +} + +static void sff_8079_show_connector(const uint8_t *data, struct sff_item *items) +{ + sff_8024_show_connector(data, 2, items); +} + +static void sff_8079_show_transceiver(const uint8_t *data, struct sff_item *items) +{ + static const char *name = "Transceiver type"; + char val_string[SFF_ITEM_VAL_COMPOSE_SIZE]; + + snprintf(val_string, sizeof(val_string), + "0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x", + data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10], data[36]); + add_item_string(items, "Transceiver codes", val_string); + + /* 10G Ethernet Compliance Codes */ + if (data[3] & (1 << 7)) + add_item_string(items, "10G Ethernet transceiver type", + "10G Ethernet: 10G Base-ER [SFF-8472 rev10.4 onwards]"); + if (data[3] & (1 << 6)) + add_item_string(items, name, "10G Ethernet: 10G Base-LRM"); + if (data[3] & (1 << 5)) + add_item_string(items, name, "10G Ethernet: 10G Base-LR"); + if (data[3] & (1 << 4)) + add_item_string(items, name, "10G Ethernet: 10G Base-SR"); + + /* Infiniband Compliance Codes */ + if (data[3] & (1 << 3)) + add_item_string(items, name, "Infiniband: 1X SX"); + if (data[3] & (1 << 2)) + add_item_string(items, name, "Infiniband: 1X LX"); + if (data[3] & (1 << 1)) + add_item_string(items, name, "Infiniband: 1X Copper Active"); + if (data[3] & (1 << 0)) + add_item_string(items, name, "Infiniband: 1X Copper Passive"); + + /* ESCON Compliance Codes */ + if (data[4] & (1 << 7)) + add_item_string(items, name, "ESCON: ESCON MMF, 1310nm LED"); + if (data[4] & (1 << 6)) + add_item_string(items, name, "ESCON: ESCON SMF, 1310nm Laser"); + + /* SONET Compliance Codes */ + if (data[4] & (1 << 5)) + add_item_string(items, name, "SONET: OC-192, short reach"); + if (data[4] & (1 << 4)) + add_item_string(items, name, "SONET: SONET reach specifier bit 1"); + if (data[4] & (1 << 3)) + add_item_string(items, name, "SONET: SONET reach specifier bit 2"); + if (data[4] & (1 << 2)) + add_item_string(items, name, "SONET: OC-48, long reach"); + if (data[4] & (1 << 1)) + add_item_string(items, name, "SONET: OC-48, intermediate reach"); + if (data[4] & (1 << 0)) + add_item_string(items, name, "SONET: OC-48, short reach"); + if (data[5] & (1 << 6)) + add_item_string(items, name, "SONET: OC-12, single mode, long reach"); + if (data[5] & (1 << 5)) + add_item_string(items, name, "SONET: OC-12, single mode, inter. reach"); + if (data[5] & (1 << 4)) + add_item_string(items, name, "SONET: OC-12, short reach"); + if (data[5] & (1 << 2)) + add_item_string(items, name, "SONET: OC-3, single mode, long reach"); + if (data[5] & (1 << 1)) + add_item_string(items, name, "SONET: OC-3, single mode, inter. reach"); + if (data[5] & (1 << 0)) + add_item_string(items, name, "SONET: OC-3, short reach"); + + /* Ethernet Compliance Codes */ + if (data[6] & (1 << 7)) + add_item_string(items, name, "Ethernet: BASE-PX"); + if (data[6] & (1 << 6)) + add_item_string(items, name, "Ethernet: BASE-BX10"); + if (data[6] & (1 << 5)) + add_item_string(items, name, "Ethernet: 100BASE-FX"); + if (data[6] & (1 << 4)) + add_item_string(items, name, "Ethernet: 100BASE-LX/LX10"); + if (data[6] & (1 << 3)) + add_item_string(items, name, "Ethernet: 1000BASE-T"); + if (data[6] & (1 << 2)) + add_item_string(items, name, "Ethernet: 1000BASE-CX"); + if (data[6] & (1 << 1)) + add_item_string(items, name, "Ethernet: 1000BASE-LX"); + if (data[6] & (1 << 0)) + add_item_string(items, name, "Ethernet: 1000BASE-SX"); + + /* Fibre Channel link length */ + if (data[7] & (1 << 7)) + add_item_string(items, name, "FC: very long distance (V)"); + if (data[7] & (1 << 6)) + add_item_string(items, name, "FC: short distance (S)"); + if (data[7] & (1 << 5)) + add_item_string(items, name, "FC: intermediate distance (I)"); + if (data[7] & (1 << 4)) + add_item_string(items, name, "FC: long distance (L)"); + if (data[7] & (1 << 3)) + add_item_string(items, name, "FC: medium distance (M)"); + + /* Fibre Channel transmitter technology */ + if (data[7] & (1 << 2)) + add_item_string(items, name, "FC: Shortwave laser, linear Rx (SA)"); + if (data[7] & (1 << 1)) + add_item_string(items, name, "FC: Longwave laser (LC)"); + if (data[7] & (1 << 0)) + add_item_string(items, name, "FC: Electrical inter-enclosure (EL)"); + if (data[8] & (1 << 7)) + add_item_string(items, name, "FC: Electrical intra-enclosure (EL)"); + if (data[8] & (1 << 6)) + add_item_string(items, name, "FC: Shortwave laser w/o OFC (SN)"); + if (data[8] & (1 << 5)) + add_item_string(items, name, "FC: Shortwave laser with OFC (SL)"); + if (data[8] & (1 << 4)) + add_item_string(items, name, "FC: Longwave laser (LL)"); + if (data[8] & (1 << 3)) + add_item_string(items, name, "Active Cable"); + if (data[8] & (1 << 2)) + add_item_string(items, name, "Passive Cable"); + if (data[8] & (1 << 1)) + add_item_string(items, name, "FC: Copper FC-BaseT"); + + /* Fibre Channel transmission media */ + if (data[9] & (1 << 7)) + add_item_string(items, name, "FC: Twin Axial Pair (TW)"); + if (data[9] & (1 << 6)) + add_item_string(items, name, "FC: Twisted Pair (TP)"); + if (data[9] & (1 << 5)) + add_item_string(items, name, "FC: Miniature Coax (MI)"); + if (data[9] & (1 << 4)) + add_item_string(items, name, "FC: Video Coax (TV)"); + if (data[9] & (1 << 3)) + add_item_string(items, name, "FC: Multimode, 62.5um (M6)"); + if (data[9] & (1 << 2)) + add_item_string(items, name, "FC: Multimode, 50um (M5)"); + if (data[9] & (1 << 0)) + add_item_string(items, name, "FC: Single Mode (SM)"); + + /* Fibre Channel speed */ + if (data[10] & (1 << 7)) + add_item_string(items, name, "FC: 1200 MBytes/sec"); + if (data[10] & (1 << 6)) + add_item_string(items, name, "FC: 800 MBytes/sec"); + if (data[10] & (1 << 4)) + add_item_string(items, name, "FC: 400 MBytes/sec"); + if (data[10] & (1 << 2)) + add_item_string(items, name, "FC: 200 MBytes/sec"); + if (data[10] & (1 << 0)) + add_item_string(items, name, "FC: 100 MBytes/sec"); + + /* Extended Specification Compliance Codes from SFF-8024 */ + switch (data[36]) { + case 0x1: + add_item_string(items, name, + "Extended: 100G AOC or 25GAUI C2M AOC with worst BER of 5x10^(-5)"); + break; + case 0x2: + add_item_string(items, name, "Extended: 100G Base-SR4 or 25GBase-SR"); + break; + case 0x3: + add_item_string(items, name, "Extended: 100G Base-LR4 or 25GBase-LR"); + break; + case 0x4: + add_item_string(items, name, "Extended: 100G Base-ER4 or 25GBase-ER"); + break; + case 0x8: + add_item_string(items, name, + "Extended: 100G ACC or 25GAUI C2M ACC with worst BER of 5x10^(-5)"); + break; + case 0xb: + add_item_string(items, name, "Extended: 100G Base-CR4 or 25G Base-CR CA-L"); + break; + case 0xc: + add_item_string(items, name, "Extended: 25G Base-CR CA-S"); + break; + case 0xd: + add_item_string(items, name, "Extended: 25G Base-CR CA-N"); + break; + case 0x16: + add_item_string(items, name, "Extended: 10Gbase-T with SFI electrical interface"); + break; + case 0x18: + add_item_string(items, name, + "Extended: 100G AOC or 25GAUI C2M AOC with worst BER of 10^(-12)"); + break; + case 0x19: + add_item_string(items, name, + "Extended: 100G ACC or 25GAUI C2M ACC with worst BER of 10^(-12)"); + break; + case 0x1c: + add_item_string(items, name, "Extended: 10Gbase-T Short Reach"); + break; + default: + break; + } +} + +static void sff_8079_show_encoding(const uint8_t *data, struct sff_item *items) +{ + sff_8024_show_encoding(data, 11, RTE_ETH_MODULE_SFF_8472, items); +} + +static void sff_8079_show_rate_identifier(const uint8_t *data, struct sff_item *items) +{ + char val_string[SFF_ITEM_VAL_COMPOSE_SIZE]; + + snprintf(val_string, sizeof(val_string), "0x%02x", data[13]); + + switch (data[13]) { + case 0x00: + printf(" (unspecified)\n"); + strlcat(val_string, " (unspecified)", sizeof(val_string)); + break; + case 0x01: + strlcat(val_string, " (4/2/1G Rate_Select & AS0/AS1)", sizeof(val_string)); + break; + case 0x02: + strlcat(val_string, " (8/4/2G Rx Rate_Select only)", sizeof(val_string)); + break; + case 0x03: + strlcat(val_string, " (8/4/2G Independent Rx & Tx Rate_Select)", + sizeof(val_string)); + break; + case 0x04: + strlcat(val_string, " (8/4/2G Tx Rate_Select only)", sizeof(val_string)); + break; + default: + strlcat(val_string, " (reserved or unknown)", sizeof(val_string)); + break; + } + add_item_string(items, "Rate identifier", val_string); +} + +static void sff_8079_show_oui(const uint8_t *data, struct sff_item *items) +{ + sff_8024_show_oui(data, 37, items); +} + +static void +sff_8079_show_wavelength_or_copper_compliance(const uint8_t *data, + struct sff_item *items) +{ + char val_string[SFF_ITEM_VAL_COMPOSE_SIZE]; + + if (data[8] & (1 << 2)) { + snprintf(val_string, sizeof(val_string), "0x%02x", data[60]); + switch (data[60]) { + case 0x00: + strlcat(val_string, " (unspecified)", sizeof(val_string)); + break; + case 0x01: + strlcat(val_string, " (SFF-8431 appendix E)", sizeof(val_string)); + break; + default: + strlcat(val_string, " (unknown)", sizeof(val_string)); + break; + } + strlcat(val_string, " [SFF-8472 rev10.4 only]", sizeof(val_string)); + add_item_string(items, "Passive Cu cmplnce.", val_string); + } else if (data[8] & (1 << 3)) { + snprintf(val_string, sizeof(val_string), "0x%02x", data[60]); + switch (data[60]) { + case 0x00: + strlcat(val_string, " (unspecified)", sizeof(val_string)); + break; + case 0x01: + strlcat(val_string, " (SFF-8431 appendix E)", sizeof(val_string)); + break; + case 0x04: + strlcat(val_string, " (SFF-8431 limiting)", sizeof(val_string)); + break; + default: + strlcat(val_string, " (unknown)", sizeof(val_string)); + break; + } + strlcat(val_string, " [SFF-8472 rev10.4 only]", sizeof(val_string)); + add_item_string(items, "Active Cu cmplnce.", val_string); + } else { + snprintf(val_string, sizeof(val_string), "%unm", (data[60] << 8) | data[61]); + add_item_string(items, "Laser wavelength", val_string); + } +} + +static void sff_8079_show_options(const uint8_t *data, struct sff_item *items) +{ + static const char *name = "Option"; + char val_string[SFF_ITEM_VAL_COMPOSE_SIZE]; + + snprintf(val_string, sizeof(val_string), "0x%02x 0x%02x", data[64], data[65]); + add_item_string(items, "Option values", val_string); + + if (data[65] & (1 << 1)) + add_item_string(items, name, "RX_LOS implemented"); + if (data[65] & (1 << 2)) + add_item_string(items, name, "RX_LOS implemented, inverted"); + if (data[65] & (1 << 3)) + add_item_string(items, name, "TX_FAULT implemented"); + if (data[65] & (1 << 4)) + add_item_string(items, name, "TX_DISABLE implemented"); + if (data[65] & (1 << 5)) + add_item_string(items, name, "RATE_SELECT implemented"); + if (data[65] & (1 << 6)) + add_item_string(items, name, "Tunable transmitter technology"); + if (data[65] & (1 << 7)) + add_item_string(items, name, "Receiver decision threshold implemented"); + if (data[64] & (1 << 0)) + add_item_string(items, name, "Linear receiver output implemented"); + if (data[64] & (1 << 1)) + add_item_string(items, name, "Power level 2 requirement"); + if (data[64] & (1 << 2)) + add_item_string(items, name, "Cooled transceiver implemented"); + if (data[64] & (1 << 3)) + add_item_string(items, name, "Retimer or CDR implemented"); + if (data[64] & (1 << 4)) + add_item_string(items, name, "Paging implemented"); + if (data[64] & (1 << 5)) + add_item_string(items, name, "Power level 3 requirement"); +} + +void sff_8079_show_all(const uint8_t *data, struct sff_item *items) +{ + sff_8079_show_identifier(data, items); + if (((data[0] == 0x02) || (data[0] == 0x03)) && (data[1] == 0x04)) { + unsigned int br_nom, br_min, br_max; + char val_string[SFF_ITEM_VAL_COMPOSE_SIZE]; + + if (data[12] == 0) { + br_nom = br_min = br_max = 0; + } else if (data[12] == 255) { + br_nom = data[66] * 250; + br_max = data[67]; + br_min = data[67]; + } else { + br_nom = data[12] * 100; + br_max = data[66]; + br_min = data[67]; + } + sff_8079_show_ext_identifier(data, items); + sff_8079_show_connector(data, items); + sff_8079_show_transceiver(data, items); + sff_8079_show_encoding(data, items); + + snprintf(val_string, sizeof(val_string), "%uMBd", br_nom); + add_item_string(items, "BR, Nominal", val_string); + + sff_8079_show_rate_identifier(data, items); + sff_show_value_with_unit(data, 14, + "Length (SMF,km)", 1, "km", items); + sff_show_value_with_unit(data, 15, "Length (SMF)", 100, "m", items); + sff_show_value_with_unit(data, 16, "Length (50um)", 10, "m", items); + sff_show_value_with_unit(data, 17, + "Length (62.5um)", 10, "m", items); + sff_show_value_with_unit(data, 18, "Length (Copper)", 1, "m", items); + sff_show_value_with_unit(data, 19, "Length (OM3)", 10, "m", items); + sff_8079_show_wavelength_or_copper_compliance(data, items); + sff_show_ascii(data, 20, 35, "Vendor name", items); + sff_8079_show_oui(data, items); + sff_show_ascii(data, 40, 55, "Vendor PN", items); + sff_show_ascii(data, 56, 59, "Vendor rev", items); + sff_8079_show_options(data, items); + + snprintf(val_string, sizeof(val_string), "%u%%", br_max); + add_item_string(items, "BR margin, max", val_string); + snprintf(val_string, sizeof(val_string), "%u%%", br_min); + add_item_string(items, "BR margin, min", val_string); + + sff_show_ascii(data, 68, 83, "Vendor SN", items); + sff_show_ascii(data, 84, 91, "Date code", items); + } +} -- 2.25.1