From owner-svn-src-head@freebsd.org Wed May 16 17:55:17 2018 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 99A5DEF040C; Wed, 16 May 2018 17:55:17 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4971D73A01; Wed, 16 May 2018 17:55:17 +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 118B71D7C7; Wed, 16 May 2018 17:55:17 +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 w4GHtG9S028122; Wed, 16 May 2018 17:55:16 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4GHtGFm028121; Wed, 16 May 2018 17:55:16 GMT (envelope-from np@FreeBSD.org) Message-Id: <201805161755.w4GHtGFm028121@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Wed, 16 May 2018 17:55:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333682 - head/sys/dev/cxgbe X-SVN-Group: head X-SVN-Commit-Author: np X-SVN-Commit-Paths: head/sys/dev/cxgbe X-SVN-Commit-Revision: 333682 X-SVN-Commit-Repository: base 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.26 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: Wed, 16 May 2018 17:55:17 -0000 Author: np Date: Wed May 16 17:55:16 2018 New Revision: 333682 URL: https://svnweb.freebsd.org/changeset/base/333682 Log: cxgbe(4): Fall back to a failsafe configuration built into the firmware if an error is reported while pre-processing the configuration file that the driver attempted to use. Also, allow the user to explicitly use the built-in configuration with hw.cxgbe.config_file="built-in" MFC after: 2 days Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/t4_main.c Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Wed May 16 17:54:40 2018 (r333681) +++ head/sys/dev/cxgbe/t4_main.c Wed May 16 17:55:16 2018 (r333682) @@ -379,9 +379,10 @@ int t4_intr_types = INTR_MSIX | INTR_MSI | INTR_INTX; TUNABLE_INT("hw.cxgbe.interrupt_types", &t4_intr_types); /* - * Configuration file. + * Configuration file. All the _CF names here are special. */ #define DEFAULT_CF "default" +#define BUILTIN_CF "built-in" #define FLASH_CF "flash" #define UWIRE_CF "uwire" #define FPGA_CF "fpga" @@ -3342,7 +3343,8 @@ partition_resources(struct adapter *sc, const struct f snprintf(sc->cfg_file, sizeof(sc->cfg_file), UWIRE_CF); if (is_fpga(sc)) snprintf(sc->cfg_file, sizeof(sc->cfg_file), FPGA_CF); - } + } else if (strncmp(t4_cfg_file, BUILTIN_CF, sizeof(t4_cfg_file)) == 0) + goto use_built_in_config; /* go straight to config. */ /* * We need to load another module if the profile is anything except @@ -3453,8 +3455,31 @@ use_config_on_flash: if (rc != 0) { device_printf(sc->dev, "failed to pre-process config file: %d " - "(mtype %d, moff 0x%x).\n", rc, mtype, moff); - goto done; + "(mtype %d, moff 0x%x). Will reset the firmware and retry " + "with the built-in configuration.\n", rc, mtype, moff); + + rc = -t4_fw_reset(sc, sc->mbox, F_PIORSTMODE | F_PIORST); + if (rc != 0) { + device_printf(sc->dev, + "firmware reset failed: %d.\n", rc); + if (rc != ETIMEDOUT && rc != EIO) { + t4_fw_bye(sc, sc->mbox); + sc->flags &= ~FW_OK; + } + goto done; + } + snprintf(sc->cfg_file, sizeof(sc->cfg_file), "%s", "built-in"); +use_built_in_config: + bzero(&caps, sizeof(caps)); + caps.op_to_write = htobe32(V_FW_CMD_OP(FW_CAPS_CONFIG_CMD) | + F_FW_CMD_REQUEST | F_FW_CMD_READ); + caps.cfvalid_to_len16 = htobe32(FW_LEN16(caps)); + rc = t4_wr_mbox(sc, sc->mbox, &caps, sizeof(caps), &caps); + if (rc != 0) { + device_printf(sc->dev, + "built-in configuration failed: %d.\n", rc); + goto done; + } } finicsum = be32toh(caps.finicsum);