From owner-svn-src-all@freebsd.org Tue Mar 8 08:59:36 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 268AFAC24F3; Tue, 8 Mar 2016 08:59:36 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 DCB99302; Tue, 8 Mar 2016 08:59:35 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u288xYNL092477; Tue, 8 Mar 2016 08:59:34 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u288xYNL092474; Tue, 8 Mar 2016 08:59:34 GMT (envelope-from np@FreeBSD.org) Message-Id: <201603080859.u288xYNL092474@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Tue, 8 Mar 2016 08:59:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r296493 - in head/sys/dev/cxgbe: . common 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.21 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: Tue, 08 Mar 2016 08:59:36 -0000 Author: np Date: Tue Mar 8 08:59:34 2016 New Revision: 296493 URL: https://svnweb.freebsd.org/changeset/base/296493 Log: cxgbe(4): Use t4_link_down_rc_str in shared code to decode the reason the link is down, instead of doing it in OS specific code. Modified: head/sys/dev/cxgbe/common/common.h head/sys/dev/cxgbe/common/t4_hw.c head/sys/dev/cxgbe/t4_main.c Modified: head/sys/dev/cxgbe/common/common.h ============================================================================== --- head/sys/dev/cxgbe/common/common.h Tue Mar 8 08:57:53 2016 (r296492) +++ head/sys/dev/cxgbe/common/common.h Tue Mar 8 08:59:34 2016 (r296493) @@ -692,6 +692,7 @@ int t4_sge_ctxt_rd(struct adapter *adap, int t4_sge_ctxt_rd_bd(struct adapter *adap, unsigned int cid, enum ctxt_type ctype, u32 *data); int t4_sge_ctxt_flush(struct adapter *adap, unsigned int mbox); +const char *t4_link_down_rc_str(unsigned char link_down_rc); int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl); int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox, u32 addr, u32 val); int t4_sched_config(struct adapter *adapter, int type, int minmaxen, Modified: head/sys/dev/cxgbe/common/t4_hw.c ============================================================================== --- head/sys/dev/cxgbe/common/t4_hw.c Tue Mar 8 08:57:53 2016 (r296492) +++ head/sys/dev/cxgbe/common/t4_hw.c Tue Mar 8 08:59:34 2016 (r296493) @@ -7430,6 +7430,31 @@ int t4_ofld_eq_free(struct adapter *adap } /** + * t4_link_down_rc_str - return a string for a Link Down Reason Code + * @link_down_rc: Link Down Reason Code + * + * Returns a string representation of the Link Down Reason Code. + */ +const char *t4_link_down_rc_str(unsigned char link_down_rc) +{ + static const char *reason[] = { + "Link Down", + "Remote Fault", + "Auto-negotiation Failure", + "Reserved3", + "Insufficient Airflow", + "Unable To Determine Reason", + "No RX Signal Detected", + "Reserved7", + }; + + if (link_down_rc >= ARRAY_SIZE(reason)) + return "Bad Reason Code"; + + return reason[link_down_rc]; +} + +/** * t4_handle_fw_rpl - process a FW reply message * @adap: the adapter * @rpl: start of the FW message Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Tue Mar 8 08:57:53 2016 (r296492) +++ head/sys/dev/cxgbe/t4_main.c Tue Mar 8 08:59:34 2016 (r296493) @@ -6020,10 +6020,6 @@ sysctl_linkdnrc(SYSCTL_HANDLER_ARGS) int rc = 0; struct port_info *pi = arg1; struct sbuf *sb; - static const char *linkdnreasons[] = { - "non-specific", "remote fault", "autoneg failed", "reserved3", - "PHY overheated", "unknown", "rx los", "reserved7" - }; rc = sysctl_wire_old_buffer(req, 0); if (rc != 0) @@ -6034,10 +6030,8 @@ sysctl_linkdnrc(SYSCTL_HANDLER_ARGS) if (pi->linkdnrc < 0) sbuf_printf(sb, "n/a"); - else if (pi->linkdnrc < nitems(linkdnreasons)) - sbuf_printf(sb, "%s", linkdnreasons[pi->linkdnrc]); else - sbuf_printf(sb, "%d", pi->linkdnrc); + sbuf_printf(sb, "%s", t4_link_down_rc_str(pi->linkdnrc)); rc = sbuf_finish(sb); sbuf_delete(sb);