From owner-svn-src-head@freebsd.org Thu Feb 7 05:06:31 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DDE4414C4A40; Thu, 7 Feb 2019 05:06:30 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7EABF6F24A; Thu, 7 Feb 2019 05:06:30 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3CF9418364; Thu, 7 Feb 2019 05:06:30 +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 x1756UHS062757; Thu, 7 Feb 2019 05:06:30 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x1756TaL062754; Thu, 7 Feb 2019 05:06:29 GMT (envelope-from np@FreeBSD.org) Message-Id: <201902070506.x1756TaL062754@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Thu, 7 Feb 2019 05:06:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r343861 - in head/sys/dev/cxgbe: . common X-SVN-Group: head X-SVN-Commit-Author: np X-SVN-Commit-Paths: in head/sys/dev/cxgbe: . common X-SVN-Commit-Revision: 343861 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 7EABF6F24A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.951,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 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, 07 Feb 2019 05:06:31 -0000 Author: np Date: Thu Feb 7 05:06:29 2019 New Revision: 343861 URL: https://svnweb.freebsd.org/changeset/base/343861 Log: cxgbe(4): Auto-dump the device log on a mailbox timeout or when the firmware reports an error in pcie_fw. Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/adapter.h head/sys/dev/cxgbe/common/t4_hw.c head/sys/dev/cxgbe/t4_main.c Modified: head/sys/dev/cxgbe/adapter.h ============================================================================== --- head/sys/dev/cxgbe/adapter.h Thu Feb 7 04:50:16 2019 (r343860) +++ head/sys/dev/cxgbe/adapter.h Thu Feb 7 05:06:29 2019 (r343861) @@ -1164,6 +1164,7 @@ void free_atid(struct adapter *, int); void release_tid(struct adapter *, int, struct sge_wrq *); int cxgbe_media_change(struct ifnet *); void cxgbe_media_status(struct ifnet *, struct ifmediareq *); +void t4_os_dump_devlog(struct adapter *); #ifdef DEV_NETMAP /* t4_netmap.c */ Modified: head/sys/dev/cxgbe/common/t4_hw.c ============================================================================== --- head/sys/dev/cxgbe/common/t4_hw.c Thu Feb 7 04:50:16 2019 (r343860) +++ head/sys/dev/cxgbe/common/t4_hw.c Thu Feb 7 05:06:29 2019 (r343861) @@ -212,9 +212,11 @@ static void t4_report_fw_error(struct adapter *adap) pcie_fw = t4_read_reg(adap, A_PCIE_FW); if (pcie_fw & F_PCIE_FW_ERR) { + adap->flags &= ~FW_OK; CH_ERR(adap, "firmware reports adapter error: %s (0x%08x)\n", reason[G_PCIE_FW_EVAL(pcie_fw)], pcie_fw); - adap->flags &= ~FW_OK; + if (pcie_fw != 0xffffffff) + t4_os_dump_devlog(adap); } } @@ -488,13 +490,19 @@ int t4_wr_mbox_meat_timeout(struct adapter *adap, int * the error and also check to see if the firmware reported any * errors ... */ - ret = (pcie_fw & F_PCIE_FW_ERR) ? -ENXIO : -ETIMEDOUT; CH_ERR(adap, "command %#x in mbox %d timed out (0x%08x).\n", *(const u8 *)cmd, mbox, pcie_fw); CH_DUMP_MBOX(adap, mbox, 0, "cmdsent", cmd_rpl, true); CH_DUMP_MBOX(adap, mbox, data_reg, "current", NULL, true); - t4_report_fw_error(adap); + if (pcie_fw & F_PCIE_FW_ERR) { + ret = -ENXIO; + t4_report_fw_error(adap); + } else { + ret = -ETIMEDOUT; + t4_os_dump_devlog(adap); + } + t4_fatal_err(adap, true); return ret; } Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Thu Feb 7 04:50:16 2019 (r343860) +++ head/sys/dev/cxgbe/t4_main.c Thu Feb 7 05:06:29 2019 (r343861) @@ -7625,19 +7625,18 @@ static const char * const devlog_facility_strings[] = }; static int -sysctl_devlog(SYSCTL_HANDLER_ARGS) +sbuf_devlog(struct adapter *sc, struct sbuf *sb, int flags) { - struct adapter *sc = arg1; + int i, j, rc, nentries, first = 0; struct devlog_params *dparams = &sc->params.devlog; struct fw_devlog_e *buf, *e; - int i, j, rc, nentries, first = 0; - struct sbuf *sb; uint64_t ftstamp = UINT64_MAX; if (dparams->addr == 0) return (ENXIO); - buf = malloc(dparams->size, M_CXGBE, M_NOWAIT); + MPASS(flags == M_WAITOK || flags == M_NOWAIT); + buf = malloc(dparams->size, M_CXGBE, M_ZERO | flags); if (buf == NULL) return (ENOMEM); @@ -7666,15 +7665,6 @@ sysctl_devlog(SYSCTL_HANDLER_ARGS) if (buf[first].timestamp == 0) goto done; /* nothing in the log */ - rc = sysctl_wire_old_buffer(req, 0); - if (rc != 0) - goto done; - - sb = sbuf_new_for_sysctl(NULL, NULL, 4096, req); - if (sb == NULL) { - rc = ENOMEM; - goto done; - } sbuf_printf(sb, "%10s %15s %8s %8s %s\n", "Seq#", "Tstamp", "Level", "Facility", "Message"); @@ -7697,12 +7687,49 @@ sysctl_devlog(SYSCTL_HANDLER_ARGS) if (++i == nentries) i = 0; } while (i != first); - - rc = sbuf_finish(sb); - sbuf_delete(sb); done: free(buf, M_CXGBE); return (rc); +} + +static int +sysctl_devlog(SYSCTL_HANDLER_ARGS) +{ + struct adapter *sc = arg1; + int rc; + struct sbuf *sb; + + rc = sysctl_wire_old_buffer(req, 0); + if (rc != 0) + return (rc); + sb = sbuf_new_for_sysctl(NULL, NULL, 4096, req); + if (sb == NULL) + return (ENOMEM); + + rc = sbuf_devlog(sc, sb, M_WAITOK); + if (rc == 0) + rc = sbuf_finish(sb); + sbuf_delete(sb); + return (rc); +} + +void +t4_os_dump_devlog(struct adapter *sc) +{ + int rc; + struct sbuf sb; + + if (sbuf_new(&sb, NULL, 4096, SBUF_AUTOEXTEND) != &sb) + return; + rc = sbuf_devlog(sc, &sb, M_NOWAIT); + if (rc == 0) { + rc = sbuf_finish(&sb); + if (rc == 0) { + log(LOG_DEBUG, "%s: device log follows.\n%s", + device_get_nameunit(sc->dev), sbuf_data(&sb)); + } + } + sbuf_delete(&sb); } static int