mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-23 15:32:33 +00:00
c7634180fc
Refreshed all patches. Remove upstreamed: - 023-0013-crypto-crypto4xx-fix-AES-CTR-blocksize-value.patch - 023-0014-crypto-crypto4xx-fix-blocksize-for-cfb-and-ofb.patch - 023-0015-crypto-crypto4xx-block-ciphers-should-only-accept-co.patch - 950-0252-staging-bcm2835_camera-Ensure-all-buffers-are-return.patch - 950-0253-staging-bcm2835-camera-Remove-check-of-the-number-of.patch - 950-0254-staging-bcm2835-camera-Handle-empty-EOS-buffers-whil.patch - 950-0489-staging-mmal-vchiq-Replace-spinlock-protecting-conte.patch - 0021-ARM-dts-gemini-Fix-up-DNS-313-compatible-string.patch - 049-v4.20-mips-remove-superfluous-check-for-linux.patch - 100-MIPS-fix-build-on-non-linux-hosts.patch - 303-MIPS-Fix-bounds-check-virt_addr_valid.patch - 0002-usb-dwc2-use-a-longer-AHB-idle-timeout-in-dwc2_core_.patch Altered patches: - 950-0267-staging-vc04_services-Split-vchiq-mmal-into-a-module.patch - 700-net-add-qualcomm-mdio-and-phy.patch Fixes: - CVE-2019-3846 New symbol: - AX88796B_PHY Compile-tested on: cns3xxx, imx6 Runtime-tested on: cns3xxx, imx6 Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
298 lines
8.1 KiB
Diff
298 lines
8.1 KiB
Diff
From 4ce55fb01c473bf1ad2048f8b4db62dca392e6d2 Mon Sep 17 00:00:00 2001
|
|
From: Russell King <rmk+kernel@arm.linux.org.uk>
|
|
Date: Sun, 13 Sep 2015 01:06:31 +0100
|
|
Subject: [PATCH] sfp: display SFP module information
|
|
|
|
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
|
|
---
|
|
drivers/net/phy/sfp.c | 261 +++++++++++++++++++++++++++++++++++++++++-
|
|
1 file changed, 258 insertions(+), 3 deletions(-)
|
|
|
|
--- a/drivers/net/phy/sfp.c
|
|
+++ b/drivers/net/phy/sfp.c
|
|
@@ -1132,6 +1132,184 @@ static void sfp_hwmon_remove(struct sfp
|
|
}
|
|
#endif
|
|
|
|
+static const char *sfp_link_len(char *buf, size_t size, unsigned int length,
|
|
+ unsigned int multiplier)
|
|
+{
|
|
+ if (length == 0)
|
|
+ return "unsupported/unspecified";
|
|
+
|
|
+ if (length == 255) {
|
|
+ *buf++ = '>';
|
|
+ size -= 1;
|
|
+ length -= 1;
|
|
+ }
|
|
+
|
|
+ length *= multiplier;
|
|
+
|
|
+ if (length >= 1000)
|
|
+ snprintf(buf, size, "%u.%0*ukm",
|
|
+ length / 1000,
|
|
+ multiplier > 100 ? 1 :
|
|
+ multiplier > 10 ? 2 : 3,
|
|
+ length % 1000);
|
|
+ else
|
|
+ snprintf(buf, size, "%um", length);
|
|
+
|
|
+ return buf;
|
|
+}
|
|
+
|
|
+struct bitfield {
|
|
+ unsigned int mask;
|
|
+ unsigned int val;
|
|
+ const char *str;
|
|
+};
|
|
+
|
|
+static const struct bitfield sfp_options[] = {
|
|
+ {
|
|
+ .mask = SFP_OPTIONS_HIGH_POWER_LEVEL,
|
|
+ .val = SFP_OPTIONS_HIGH_POWER_LEVEL,
|
|
+ .str = "hpl",
|
|
+ }, {
|
|
+ .mask = SFP_OPTIONS_PAGING_A2,
|
|
+ .val = SFP_OPTIONS_PAGING_A2,
|
|
+ .str = "paginga2",
|
|
+ }, {
|
|
+ .mask = SFP_OPTIONS_RETIMER,
|
|
+ .val = SFP_OPTIONS_RETIMER,
|
|
+ .str = "retimer",
|
|
+ }, {
|
|
+ .mask = SFP_OPTIONS_COOLED_XCVR,
|
|
+ .val = SFP_OPTIONS_COOLED_XCVR,
|
|
+ .str = "cooled",
|
|
+ }, {
|
|
+ .mask = SFP_OPTIONS_POWER_DECL,
|
|
+ .val = SFP_OPTIONS_POWER_DECL,
|
|
+ .str = "powerdecl",
|
|
+ }, {
|
|
+ .mask = SFP_OPTIONS_RX_LINEAR_OUT,
|
|
+ .val = SFP_OPTIONS_RX_LINEAR_OUT,
|
|
+ .str = "rxlinear",
|
|
+ }, {
|
|
+ .mask = SFP_OPTIONS_RX_DECISION_THRESH,
|
|
+ .val = SFP_OPTIONS_RX_DECISION_THRESH,
|
|
+ .str = "rxthresh",
|
|
+ }, {
|
|
+ .mask = SFP_OPTIONS_TUNABLE_TX,
|
|
+ .val = SFP_OPTIONS_TUNABLE_TX,
|
|
+ .str = "tunabletx",
|
|
+ }, {
|
|
+ .mask = SFP_OPTIONS_RATE_SELECT,
|
|
+ .val = SFP_OPTIONS_RATE_SELECT,
|
|
+ .str = "ratesel",
|
|
+ }, {
|
|
+ .mask = SFP_OPTIONS_TX_DISABLE,
|
|
+ .val = SFP_OPTIONS_TX_DISABLE,
|
|
+ .str = "txdisable",
|
|
+ }, {
|
|
+ .mask = SFP_OPTIONS_TX_FAULT,
|
|
+ .val = SFP_OPTIONS_TX_FAULT,
|
|
+ .str = "txfault",
|
|
+ }, {
|
|
+ .mask = SFP_OPTIONS_LOS_INVERTED,
|
|
+ .val = SFP_OPTIONS_LOS_INVERTED,
|
|
+ .str = "los-",
|
|
+ }, {
|
|
+ .mask = SFP_OPTIONS_LOS_NORMAL,
|
|
+ .val = SFP_OPTIONS_LOS_NORMAL,
|
|
+ .str = "los+",
|
|
+ }, { }
|
|
+};
|
|
+
|
|
+static const struct bitfield diagmon[] = {
|
|
+ {
|
|
+ .mask = SFP_DIAGMON_DDM,
|
|
+ .val = SFP_DIAGMON_DDM,
|
|
+ .str = "ddm",
|
|
+ }, {
|
|
+ .mask = SFP_DIAGMON_INT_CAL,
|
|
+ .val = SFP_DIAGMON_INT_CAL,
|
|
+ .str = "intcal",
|
|
+ }, {
|
|
+ .mask = SFP_DIAGMON_EXT_CAL,
|
|
+ .val = SFP_DIAGMON_EXT_CAL,
|
|
+ .str = "extcal",
|
|
+ }, {
|
|
+ .mask = SFP_DIAGMON_RXPWR_AVG,
|
|
+ .val = SFP_DIAGMON_RXPWR_AVG,
|
|
+ .str = "rxpwravg",
|
|
+ }, { }
|
|
+};
|
|
+
|
|
+static const char *sfp_bitfield(char *out, size_t outsz, const struct bitfield *bits, unsigned int val)
|
|
+{
|
|
+ char *p = out;
|
|
+ int n;
|
|
+
|
|
+ *p = '\0';
|
|
+ while (bits->mask) {
|
|
+ if ((val & bits->mask) == bits->val) {
|
|
+ n = snprintf(p, outsz, "%s%s",
|
|
+ out != p ? ", " : "",
|
|
+ bits->str);
|
|
+ if (n == outsz)
|
|
+ break;
|
|
+ p += n;
|
|
+ outsz -= n;
|
|
+ }
|
|
+ bits++;
|
|
+ }
|
|
+
|
|
+ return out;
|
|
+}
|
|
+
|
|
+static const char *sfp_connector(unsigned int connector)
|
|
+{
|
|
+ switch (connector) {
|
|
+ case SFP_CONNECTOR_UNSPEC:
|
|
+ return "unknown/unspecified";
|
|
+ case SFP_CONNECTOR_SC:
|
|
+ return "SC";
|
|
+ case SFP_CONNECTOR_FIBERJACK:
|
|
+ return "Fiberjack";
|
|
+ case SFP_CONNECTOR_LC:
|
|
+ return "LC";
|
|
+ case SFP_CONNECTOR_MT_RJ:
|
|
+ return "MT-RJ";
|
|
+ case SFP_CONNECTOR_MU:
|
|
+ return "MU";
|
|
+ case SFP_CONNECTOR_SG:
|
|
+ return "SG";
|
|
+ case SFP_CONNECTOR_OPTICAL_PIGTAIL:
|
|
+ return "Optical pigtail";
|
|
+ case SFP_CONNECTOR_HSSDC_II:
|
|
+ return "HSSDC II";
|
|
+ case SFP_CONNECTOR_COPPER_PIGTAIL:
|
|
+ return "Copper pigtail";
|
|
+ default:
|
|
+ return "unknown";
|
|
+ }
|
|
+}
|
|
+
|
|
+static const char *sfp_encoding(unsigned int encoding)
|
|
+{
|
|
+ switch (encoding) {
|
|
+ case SFP_ENCODING_UNSPEC:
|
|
+ return "unspecified";
|
|
+ case SFP_ENCODING_8472_64B66B:
|
|
+ return "64b66b";
|
|
+ case SFP_ENCODING_8B10B:
|
|
+ return "8b10b";
|
|
+ case SFP_ENCODING_4B5B:
|
|
+ return "4b5b";
|
|
+ case SFP_ENCODING_NRZ:
|
|
+ return "NRZ";
|
|
+ case SFP_ENCODING_8472_MANCHESTER:
|
|
+ return "MANCHESTER";
|
|
+ default:
|
|
+ return "unknown";
|
|
+ }
|
|
+}
|
|
+
|
|
/* Helpers */
|
|
static void sfp_module_tx_disable(struct sfp *sfp)
|
|
{
|
|
@@ -1376,6 +1554,8 @@ static int sfp_sm_mod_probe(struct sfp *
|
|
{
|
|
/* SFP module inserted - read I2C data */
|
|
struct sfp_eeprom_id id;
|
|
+ char date[9];
|
|
+ char options[80];
|
|
bool cotsworks;
|
|
u8 check;
|
|
int ret;
|
|
@@ -1432,12 +1612,87 @@ static int sfp_sm_mod_probe(struct sfp *
|
|
|
|
sfp->id = id;
|
|
|
|
- dev_info(sfp->dev, "module %.*s %.*s rev %.*s sn %.*s dc %.*s\n",
|
|
+ date[0] = sfp->id.ext.datecode[4];
|
|
+ date[1] = sfp->id.ext.datecode[5];
|
|
+ date[2] = '-';
|
|
+ date[3] = sfp->id.ext.datecode[2];
|
|
+ date[4] = sfp->id.ext.datecode[3];
|
|
+ date[5] = '-';
|
|
+ date[6] = sfp->id.ext.datecode[0];
|
|
+ date[7] = sfp->id.ext.datecode[1];
|
|
+ date[8] = '\0';
|
|
+
|
|
+ dev_info(sfp->dev, "module %.*s %.*s rev %.*s sn %.*s dc %s\n",
|
|
(int)sizeof(id.base.vendor_name), id.base.vendor_name,
|
|
(int)sizeof(id.base.vendor_pn), id.base.vendor_pn,
|
|
(int)sizeof(id.base.vendor_rev), id.base.vendor_rev,
|
|
- (int)sizeof(id.ext.vendor_sn), id.ext.vendor_sn,
|
|
- (int)sizeof(id.ext.datecode), id.ext.datecode);
|
|
+ (int)sizeof(id.ext.vendor_sn), id.ext.vendor_sn, date);
|
|
+ dev_info(sfp->dev, " %s connector, encoding %s, nominal bitrate %u.%uGbps +%u%% -%u%%\n",
|
|
+ sfp_connector(sfp->id.base.connector),
|
|
+ sfp_encoding(sfp->id.base.encoding),
|
|
+ sfp->id.base.br_nominal / 10,
|
|
+ sfp->id.base.br_nominal % 10,
|
|
+ sfp->id.ext.br_max, sfp->id.ext.br_min);
|
|
+ dev_info(sfp->dev, " 1000BaseSX%c 1000BaseLX%c 1000BaseCX%c 1000BaseT%c 100BaseLX%c 100BaseFX%c BaseBX10%c BasePX%c\n",
|
|
+ sfp->id.base.e1000_base_sx ? '+' : '-',
|
|
+ sfp->id.base.e1000_base_lx ? '+' : '-',
|
|
+ sfp->id.base.e1000_base_cx ? '+' : '-',
|
|
+ sfp->id.base.e1000_base_t ? '+' : '-',
|
|
+ sfp->id.base.e100_base_lx ? '+' : '-',
|
|
+ sfp->id.base.e100_base_fx ? '+' : '-',
|
|
+ sfp->id.base.e_base_bx10 ? '+' : '-',
|
|
+ sfp->id.base.e_base_px ? '+' : '-');
|
|
+ dev_info(sfp->dev, " 10GBaseSR%c 10GBaseLR%c 10GBaseLRM%c 10GBaseER%c\n",
|
|
+ sfp->id.base.e10g_base_sr ? '+' : '-',
|
|
+ sfp->id.base.e10g_base_lr ? '+' : '-',
|
|
+ sfp->id.base.e10g_base_lrm ? '+' : '-',
|
|
+ sfp->id.base.e10g_base_er ? '+' : '-');
|
|
+
|
|
+ if (!sfp->id.base.sfp_ct_passive && !sfp->id.base.sfp_ct_active &&
|
|
+ !sfp->id.base.e1000_base_t) {
|
|
+ char len_9um[16], len_om[16];
|
|
+
|
|
+ dev_info(sfp->dev, " Wavelength %unm, fiber lengths:\n",
|
|
+ be16_to_cpup(&sfp->id.base.optical_wavelength));
|
|
+
|
|
+ if (sfp->id.base.link_len[0] == 255)
|
|
+ strcpy(len_9um, ">254km");
|
|
+ else if (sfp->id.base.link_len[1] && sfp->id.base.link_len[1] != 255)
|
|
+ sprintf(len_9um, "%um",
|
|
+ sfp->id.base.link_len[1] * 100);
|
|
+ else if (sfp->id.base.link_len[0])
|
|
+ sprintf(len_9um, "%ukm", sfp->id.base.link_len[0]);
|
|
+ else if (sfp->id.base.link_len[1] == 255)
|
|
+ strcpy(len_9um, ">25.4km");
|
|
+ else
|
|
+ strcpy(len_9um, "unsupported");
|
|
+
|
|
+ dev_info(sfp->dev, " 9µm SM : %s\n", len_9um);
|
|
+ dev_info(sfp->dev, " 62.5µm MM OM1: %s\n",
|
|
+ sfp_link_len(len_om, sizeof(len_om),
|
|
+ sfp->id.base.link_len[3], 10));
|
|
+ dev_info(sfp->dev, " 50µm MM OM2: %s\n",
|
|
+ sfp_link_len(len_om, sizeof(len_om),
|
|
+ sfp->id.base.link_len[2], 10));
|
|
+ dev_info(sfp->dev, " 50µm MM OM3: %s\n",
|
|
+ sfp_link_len(len_om, sizeof(len_om),
|
|
+ sfp->id.base.link_len[5], 10));
|
|
+ dev_info(sfp->dev, " 50µm MM OM4: %s\n",
|
|
+ sfp_link_len(len_om, sizeof(len_om),
|
|
+ sfp->id.base.link_len[4], 10));
|
|
+ } else {
|
|
+ char len[16];
|
|
+ dev_info(sfp->dev, " Copper length: %s\n",
|
|
+ sfp_link_len(len, sizeof(len),
|
|
+ sfp->id.base.link_len[4], 1));
|
|
+ }
|
|
+
|
|
+ dev_info(sfp->dev, " Options: %s\n",
|
|
+ sfp_bitfield(options, sizeof(options), sfp_options,
|
|
+ be16_to_cpu(sfp->id.ext.options)));
|
|
+ dev_info(sfp->dev, " Diagnostics: %s\n",
|
|
+ sfp_bitfield(options, sizeof(options), diagmon,
|
|
+ sfp->id.ext.diagmon));
|
|
|
|
/* Check whether we support this module */
|
|
if (!sfp->type->module_supported(&sfp->id)) {
|