From owner-svn-src-head@FreeBSD.ORG Thu Oct 23 11:01:50 2014 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 919E87E7; Thu, 23 Oct 2014 11:01:50 +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 723A5269; Thu, 23 Oct 2014 11:01:50 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9NB1ogI072303; Thu, 23 Oct 2014 11:01:50 GMT (envelope-from melifaro@FreeBSD.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9NB1oRf072302; Thu, 23 Oct 2014 11:01:50 GMT (envelope-from melifaro@FreeBSD.org) Message-Id: <201410231101.s9NB1oRf072302@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: melifaro set sender to melifaro@FreeBSD.org using -f From: "Alexander V. Chernikov" Date: Thu, 23 Oct 2014 11:01:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273541 - head/sbin/ifconfig 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.18-1 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: Thu, 23 Oct 2014 11:01:50 -0000 Author: melifaro Date: Thu Oct 23 11:01:49 2014 New Revision: 273541 URL: https://svnweb.freebsd.org/changeset/base/273541 Log: Show SFP+/QSFP memory map dump on higher verbose levels. Sponsored by: Yandex LLC MFC after: 1 week Modified: head/sbin/ifconfig/sfp.c Modified: head/sbin/ifconfig/sfp.c ============================================================================== --- head/sbin/ifconfig/sfp.c Thu Oct 23 08:29:09 2014 (r273540) +++ head/sbin/ifconfig/sfp.c Thu Oct 23 11:01:49 2014 (r273541) @@ -67,6 +67,9 @@ struct i2c_info { int chip_id; }; +static void dump_i2c_data(struct i2c_info *ii, uint8_t addr, uint8_t off, + uint8_t len); + struct _nv { int v; const char *n; @@ -327,6 +330,9 @@ get_sfp_transceiver_class(struct i2c_inf const char *tech_class; uint8_t code; + unsigned char qbuf[8]; + ii->f(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 8, (caddr_t)qbuf); + /* Check 10G Ethernet/IB first */ ii->f(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 1, (caddr_t)&code); tech_class = find_zero_bit(eth_10g, code, 1); @@ -662,6 +668,30 @@ read_i2c_generic(struct i2c_info *ii, ui } static void +dump_i2c_data(struct i2c_info *ii, uint8_t addr, uint8_t off, uint8_t len) +{ + unsigned char buf[16]; + int i, read; + + while (len > 0) { + memset(buf, 0, sizeof(buf)); + read = (len > sizeof(buf)) ? sizeof(buf) : len; + ii->f(ii, addr, off, read, buf); + if (ii->error != 0) { + fprintf(stderr, "Error reading i2c info\n"); + return; + } + + printf("\t"); + for (i = 0; i < read; i++) + printf("%02X ", buf[i]); + printf("\n"); + len -= read; + off += read; + } +} + +static void print_qsfp_status(struct i2c_info *ii, int verbose) { char buf[80], buf2[40], buf3[40]; @@ -703,6 +733,13 @@ print_qsfp_status(struct i2c_info *ii, i printf("\tlane %d: RX: %s TX: %s\n", i, buf, buf2); } } + + if (verbose > 2) { + printf("\n\tSFF8436 DUMP (0xA0 128..255 range):\n"); + dump_i2c_data(ii, SFF_8436_BASE, 128, 128); + printf("\n\tSFF8436 DUMP (0xA0 0..81 range):\n"); + dump_i2c_data(ii, SFF_8436_BASE, 0, 82); + } } static void @@ -730,12 +767,12 @@ print_sfp_status(struct i2c_info *ii, in get_sfp_connector(ii, buf3, sizeof(buf3)); if (ii->error == 0) printf("\tplugged: %s %s (%s)\n", buf, buf2, buf3); - if (verbose > 2) - printf_sfp_transceiver_descr(ii, buf, sizeof(buf)); print_sfp_vendor(ii, buf, sizeof(buf)); if (ii->error == 0) printf("\t%s\n", buf); + if (verbose > 5) + printf_sfp_transceiver_descr(ii, buf, sizeof(buf)); /* * Request current measurements iff they are provided: */ @@ -747,6 +784,11 @@ print_sfp_status(struct i2c_info *ii, in get_sfp_tx_power(ii, buf2, sizeof(buf2)); printf("\tRX: %s TX: %s\n", buf, buf2); } + + if (verbose > 2) { + printf("\n\tSFF8472 DUMP (0xA0 0..127 range):\n"); + dump_i2c_data(ii, SFF_8472_BASE, 0, 128); + } } void