From owner-svn-src-all@freebsd.org Tue Apr 30 08:08:07 2019 Return-Path: Delivered-To: svn-src-all@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 989101587A94; Tue, 30 Apr 2019 08:08:07 +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 3AB6C92402; Tue, 30 Apr 2019 08:08:07 +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 11E356C51; Tue, 30 Apr 2019 08:08:07 +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 x3U886sp073907; Tue, 30 Apr 2019 08:08:06 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3U886Ub073906; Tue, 30 Apr 2019 08:08:06 GMT (envelope-from np@FreeBSD.org) Message-Id: <201904300808.x3U886Ub073906@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Tue, 30 Apr 2019 08:08:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r346952 - stable/11/sys/dev/cxgbe X-SVN-Group: stable-11 X-SVN-Commit-Author: np X-SVN-Commit-Paths: stable/11/sys/dev/cxgbe X-SVN-Commit-Revision: 346952 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3AB6C92402 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.975,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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, 30 Apr 2019 08:08:07 -0000 Author: np Date: Tue Apr 30 08:08:06 2019 New Revision: 346952 URL: https://svnweb.freebsd.org/changeset/base/346952 Log: MFC r343264: cxgbe(4): Use a truncated firmware header for version checks. All the version numbers are towards the begining of the header. Sponsored by: Chelsio Communications Modified: stable/11/sys/dev/cxgbe/t4_main.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/cxgbe/t4_main.c ============================================================================== --- stable/11/sys/dev/cxgbe/t4_main.c Tue Apr 30 08:01:59 2019 (r346951) +++ stable/11/sys/dev/cxgbe/t4_main.c Tue Apr 30 08:08:06 2019 (r346952) @@ -3281,17 +3281,38 @@ restart: V_FW_HDR_FW_VER_BUILD(chip##FW_VERSION_BUILD)) #define FW_INTFVER(chip, intf) (chip##FW_HDR_INTFVER_##intf) +/* Just enough of fw_hdr to cover all version info. */ +struct fw_h { + __u8 ver; + __u8 chip; + __be16 len512; + __be32 fw_ver; + __be32 tp_microcode_ver; + __u8 intfver_nic; + __u8 intfver_vnic; + __u8 intfver_ofld; + __u8 intfver_ri; + __u8 intfver_iscsipdu; + __u8 intfver_iscsi; + __u8 intfver_fcoepdu; + __u8 intfver_fcoe; +}; +/* Spot check a couple of fields. */ +CTASSERT(offsetof(struct fw_h, fw_ver) == offsetof(struct fw_hdr, fw_ver)); +CTASSERT(offsetof(struct fw_h, intfver_nic) == offsetof(struct fw_hdr, intfver_nic)); +CTASSERT(offsetof(struct fw_h, intfver_fcoe) == offsetof(struct fw_hdr, intfver_fcoe)); + struct fw_info { uint8_t chip; char *kld_name; char *fw_mod_name; - struct fw_hdr fw_hdr; /* XXX: waste of space, need a sparse struct */ + struct fw_h fw_h; } fw_info[] = { { .chip = CHELSIO_T4, .kld_name = "t4fw_cfg", .fw_mod_name = "t4fw", - .fw_hdr = { + .fw_h = { .chip = FW_HDR_CHIP_T4, .fw_ver = htobe32(FW_VERSION(T4)), .intfver_nic = FW_INTFVER(T4, NIC), @@ -3307,7 +3328,7 @@ struct fw_info { .chip = CHELSIO_T5, .kld_name = "t5fw_cfg", .fw_mod_name = "t5fw", - .fw_hdr = { + .fw_h = { .chip = FW_HDR_CHIP_T5, .fw_ver = htobe32(FW_VERSION(T5)), .intfver_nic = FW_INTFVER(T5, NIC), @@ -3323,7 +3344,7 @@ struct fw_info { .chip = CHELSIO_T6, .kld_name = "t6fw_cfg", .fw_mod_name = "t6fw", - .fw_hdr = { + .fw_h = { .chip = FW_HDR_CHIP_T6, .fw_ver = htobe32(FW_VERSION(T6)), .intfver_nic = FW_INTFVER(T6, NIC), @@ -3355,7 +3376,7 @@ find_fw_info(int chip) * with? */ static int -fw_compatible(const struct fw_hdr *hdr1, const struct fw_hdr *hdr2) +fw_compatible(const struct fw_h *hdr1, const struct fw_h *hdr2) { /* short circuit if it's the exact same firmware version */ @@ -3422,8 +3443,8 @@ unload_fw_module(struct adapter *sc, const struct firm * +ve errno means a firmware install was attempted but failed. */ static int -install_kld_firmware(struct adapter *sc, struct fw_hdr *card_fw, - const struct fw_hdr *drv_fw, const char *reason, int *already) +install_kld_firmware(struct adapter *sc, struct fw_h *card_fw, + const struct fw_h *drv_fw, const char *reason, int *already) { const struct firmware *cfg, *fw; const uint32_t c = be32toh(card_fw->fw_ver); @@ -3528,7 +3549,7 @@ contact_firmware(struct adapter *sc) enum dev_state state; struct fw_info *fw_info; struct fw_hdr *card_fw; /* fw on the card */ - const struct fw_hdr *drv_fw; /* fw bundled with the driver */ + const struct fw_h *drv_fw; fw_info = find_fw_info(chip_id(sc)); if (fw_info == NULL) { @@ -3537,7 +3558,7 @@ contact_firmware(struct adapter *sc) chip_id(sc)); return (EINVAL); } - drv_fw = &fw_info->fw_hdr; + drv_fw = &fw_info->fw_h; /* Read the header of the firmware on the card */ card_fw = malloc(sizeof(*card_fw), M_CXGBE, M_ZERO | M_WAITOK); @@ -3550,7 +3571,8 @@ restart: goto done; } - rc = install_kld_firmware(sc, card_fw, drv_fw, NULL, &already); + rc = install_kld_firmware(sc, (struct fw_h *)card_fw, drv_fw, NULL, + &already); if (rc == ERESTART) goto restart; if (rc != 0) @@ -3563,7 +3585,7 @@ restart: "failed to connect to the firmware: %d, %d. " "PCIE_FW 0x%08x\n", rc, state, t4_read_reg(sc, A_PCIE_FW)); #if 0 - if (install_kld_firmware(sc, card_fw, drv_fw, + if (install_kld_firmware(sc, (struct fw_h *)card_fw, drv_fw, "not responding properly to HELLO", &already) == ERESTART) goto restart; #endif @@ -3574,7 +3596,8 @@ restart: if (rc == sc->pf) { sc->flags |= MASTER_PF; - rc = install_kld_firmware(sc, card_fw, drv_fw, NULL, &already); + rc = install_kld_firmware(sc, (struct fw_h *)card_fw, drv_fw, + NULL, &already); if (rc == ERESTART) rc = 0; else if (rc != 0)