From owner-svn-src-head@FreeBSD.ORG Sat May 16 13:11:37 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 05126D6A; Sat, 16 May 2015 13:11:37 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C134D1516; Sat, 16 May 2015 13:11:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t4GDBaN7064244; Sat, 16 May 2015 13:11:36 GMT (envelope-from melifaro@FreeBSD.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t4GDBa39064241; Sat, 16 May 2015 13:11:36 GMT (envelope-from melifaro@FreeBSD.org) Message-Id: <201505161311.t4GDBa39064241@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: melifaro set sender to melifaro@FreeBSD.org using -f From: "Alexander V. Chernikov" Date: Sat, 16 May 2015 13:11:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r283009 - in head: sbin/ifconfig sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2015 13:11:37 -0000 Author: melifaro Date: Sat May 16 13:11:35 2015 New Revision: 283009 URL: https://svnweb.freebsd.org/changeset/base/283009 Log: * Update SFF-8024 Identifier constants. * Fix SFF_8436_CC_EXT in SFF-8436 memory map. * Add SFF-8436/8636 bits (revision compliance/nominal bitrate). * Do some small style/type fixes. Modified: head/sbin/ifconfig/sfp.c head/sys/net/sff8436.h head/sys/net/sff8472.h Modified: head/sbin/ifconfig/sfp.c ============================================================================== --- head/sbin/ifconfig/sfp.c Sat May 16 12:05:26 2015 (r283008) +++ head/sbin/ifconfig/sfp.c Sat May 16 13:11:35 2015 (r283009) @@ -182,6 +182,18 @@ static struct _nv eth_1040g[] = { { 0, NULL } }; +/* SFF-8636 Rev. 2.5 table 6.3: Revision compliance */ +static struct _nv rev_compl[] = { + { 0x1, "SFF-8436 rev <=4.8" }, + { 0x2, "SFF-8436 rev <=4.8" }, + { 0x3, "SFF-8636 rev <=1.3" }, + { 0x4, "SFF-8636 rev <=1.4" }, + { 0x5, "SFF-8636 rev <=1.5" }, + { 0x6, "SFF-8636 rev <=2.0" }, + { 0x7, "SFF-8636 rev <=2.5" }, + { 0x0, "Unspecified" } +}; + const char * find_value(struct _nv *x, int value) { @@ -246,6 +258,19 @@ convert_sff_connector(char *buf, size_t } static void +convert_sff_rev_compliance(char *buf, size_t size, uint8_t value) +{ + const char *x; + + if (value > 0x07) + x = "Unallocated"; + else + x = find_value(rev_compl, value); + + snprintf(buf, size, "%s", x); +} + +static void get_sfp_identifier(struct i2c_info *ii, char *buf, size_t size) { uint8_t data; @@ -604,23 +629,50 @@ get_sfp_tx_power(struct i2c_info *ii, ch static void get_qsfp_rx_power(struct i2c_info *ii, char *buf, size_t size, int chan) { - char xbuf[2]; + uint8_t xbuf[2]; memset(xbuf, 0, sizeof(xbuf)); - read_i2c(ii, SFF_8436_BASE, SFF_8436_RX_CH1_MSB + (chan - 1) * 2, 2, xbuf); + read_i2c(ii, SFF_8436_BASE, SFF_8436_RX_CH1_MSB + (chan-1)*2, 2, xbuf); convert_sff_power(ii, buf, size, xbuf); } static void get_qsfp_tx_power(struct i2c_info *ii, char *buf, size_t size, int chan) { - char xbuf[2]; + uint8_t xbuf[2]; memset(xbuf, 0, sizeof(xbuf)); - read_i2c(ii, SFF_8436_BASE, SFF_8436_TX_CH1_MSB + (chan -1) * 2, 2, xbuf); + read_i2c(ii, SFF_8436_BASE, SFF_8436_TX_CH1_MSB + (chan-1)*2, 2, xbuf); convert_sff_power(ii, buf, size, xbuf); } +static void +get_qsfp_rev_compliance(struct i2c_info *ii, char *buf, size_t size) +{ + uint8_t xbuf; + + xbuf = 0; + read_i2c(ii, SFF_8436_BASE, SFF_8436_STATUS, 1, &xbuf); + convert_sff_rev_compliance(buf, size, xbuf); +} + +static uint32_t +get_qsfp_br(struct i2c_info *ii) +{ + uint8_t xbuf; + uint32_t rate; + + xbuf = 0; + read_i2c(ii, SFF_8436_BASE, SFF_8436_BITRATE, 1, &xbuf); + rate = xbuf * 100; + if (xbuf == 0xFF) { + read_i2c(ii, SFF_8436_BASE, SFF_8636_BITRATE, 1, &xbuf); + rate = xbuf * 250; + } + + return (rate); +} + /* * Reads i2c data from opened kernel socket. */ @@ -689,6 +741,7 @@ print_qsfp_status(struct i2c_info *ii, i { char buf[80], buf2[40], buf3[40]; uint8_t diag_type; + uint32_t bitrate; int i; /* Read diagnostic monitoring type */ @@ -715,6 +768,16 @@ print_qsfp_status(struct i2c_info *ii, i if (ii->error == 0) printf("\t%s\n", buf); + if (verbose > 1) { + get_qsfp_rev_compliance(ii, buf, sizeof(buf)); + if (ii->error == 0) + printf("\tcompliance level: %s\n", buf); + + bitrate = get_qsfp_br(ii); + if (ii->error == 0 && bitrate > 0) + printf("\tnominal bitrate: %u Mbps\n", bitrate); + } + /* Request current measurements if they are provided: */ if (ii->do_diag != 0) { get_qsfp_temp(ii, buf, sizeof(buf)); Modified: head/sys/net/sff8436.h ============================================================================== --- head/sys/net/sff8436.h Sat May 16 12:05:26 2015 (r283008) +++ head/sys/net/sff8436.h Sat May 16 13:11:35 2015 (r283009) @@ -202,7 +202,9 @@ enum { * optional features are implemented * (if any) in the transceiver * (see Table 42) */ - SFF_8436_CC_EXT = 222, /* Check code for the Extended ID + SFF_8636_BITRATE = 222, /* Nominal bit rate per channel, units + * of 250 Mbps */ + SFF_8436_CC_EXT = 223, /* Check code for the Extended ID * Fields (bytes 192-222 incl) */ SFF_8436_VENDOR_RSRVD_START = 224, SFF_8436_VENDOR_RSRVD_END = 255, Modified: head/sys/net/sff8472.h ============================================================================== --- head/sys/net/sff8472.h Sat May 16 12:05:26 2015 (r283008) +++ head/sys/net/sff8472.h Sat May 16 13:11:35 2015 (r283009) @@ -377,7 +377,7 @@ enum { /* * Table 3.2 Identifier values. - * Identifier constants has taken from SFF-8024 rev 2.2 table 4.1 + * Identifier constants has taken from SFF-8024 rev 2.9 table 4.1 * (as referenced by table 3.2 footer) * */ enum { @@ -400,28 +400,36 @@ enum { SFF_8024_ID_HD8X = 0x10, /* Shielded Mini Multilane HD 8X */ SFF_8024_ID_QSFP28 = 0x11, /* QSFP28 */ SFF_8024_ID_CXP2 = 0x12, /* CXP2 (aka CXP28) */ - SFF_8024_ID_LAST = SFF_8024_ID_CXP2 + SFF_8024_ID_CDFP = 0x13, /* CDFP (Style 1/Style 2) */ + SFF_8024_ID_SMM4 = 0x14, /* Shielded Mini Multilate HD 4X Fanout */ + SFF_8024_ID_SMM8 = 0x15, /* Shielded Mini Multilate HD 8X Fanout */ + SFF_8024_ID_CDFP3 = 0x16, /* CDFP (Style3) */ + SFF_8024_ID_LAST = SFF_8024_ID_CDFP3 }; static const char *sff_8024_id[SFF_8024_ID_LAST + 1] = {"Unknown", "GBIC", "SFF", - "SFP/SFP+", + "SFP/SFP+/SFP28", "XBI", "Xenpak", "XFP", "XFF", "XFP-E", - "XPAk", + "XPAK", "X2", - "DWDM-SFP", + "DWDM-SFP/SFP+", "QSFP", "QSFP+", "CXP", "HD4X", "HD8X", "QSFP28", - "CXP2"}; + "CXP2", + "CDFP", + "SMM4", + "SMM8", + "CDFP3"}; /* Keep compability with old definitions */ #define SFF_8472_ID_UNKNOWN SFF_8024_ID_UNKNOWN