From owner-svn-src-all@FreeBSD.ORG Wed Sep 3 11:07:50 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5847045B; Wed, 3 Sep 2014 11:07: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 433CB153E; Wed, 3 Sep 2014 11:07: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 s83B7oow065406; Wed, 3 Sep 2014 11:07:50 GMT (envelope-from melifaro@FreeBSD.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s83B7of1065405; Wed, 3 Sep 2014 11:07:50 GMT (envelope-from melifaro@FreeBSD.org) Message-Id: <201409031107.s83B7of1065405@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: melifaro set sender to melifaro@FreeBSD.org using -f From: "Alexander V. Chernikov" Date: Wed, 3 Sep 2014 11:07:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r271014 - 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-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Sep 2014 11:07:50 -0000 Author: melifaro Date: Wed Sep 3 11:07:49 2014 New Revision: 271014 URL: http://svnweb.freebsd.org/changeset/base/271014 Log: * Unconditionally turn on SIOCGI2C probing for all interfaces on "ifconfig -v". I've seen no measurable timing difference for doing additional SIOCGI2C call for system with 4k vlans. * Determine appropriate handler (SFP/QSFP) by reading identification byte (which is the same for both SFF-8472 and SFF-8436) instead of checking driver name. MFC with: r270064 Sponsored by: Yandex LLC Modified: head/sbin/ifconfig/sfp.c Modified: head/sbin/ifconfig/sfp.c ============================================================================== --- head/sbin/ifconfig/sfp.c Wed Sep 3 09:58:59 2014 (r271013) +++ head/sbin/ifconfig/sfp.c Wed Sep 3 11:07:49 2014 (r271014) @@ -753,25 +753,31 @@ void sfp_status(int s, struct ifreq *ifr, int verbose) { struct i2c_info ii; + uint8_t id_byte; memset(&ii, 0, sizeof(ii)); /* Prepare necessary into to pass to NIC handler */ ii.s = s; ii.ifr = ifr; + ii.f = read_i2c_generic; /* - * Check if we have i2c support for particular driver. - * TODO: Determine driver by original name. + * Try to read byte 0 from i2c: + * Both SFF-8472 and SFF-8436 use it as + * 'identification byte' */ - if (strncmp(ifr->ifr_name, "ix", 2) == 0) { - ii.f = read_i2c_generic; - print_sfp_status(&ii, verbose); - } else if (strncmp(ifr->ifr_name, "cxl", 3) == 0) { - ii.port_id = atoi(&ifr->ifr_name[3]); - ii.f = read_i2c_generic; - ii.cfd = -1; - print_qsfp_status(&ii, verbose); - } else + id_byte = 0; + ii.f(&ii, SFF_8472_BASE, SFF_8472_ID, 1, (caddr_t)&id_byte); + if (ii.error != 0) return; + + switch (id_byte) { + case SFF_8024_ID_QSFP: + case SFF_8024_ID_QSFPPLUS: + print_qsfp_status(&ii, verbose); + break; + default: + print_sfp_status(&ii, verbose); + }; }