svn commit: r219287 - in head/sys/dev/cxgbe: . common
Navdeep Parhar
np at FreeBSD.org
Sat Mar 5 03:12:51 UTC 2011
Author: np
Date: Sat Mar 5 03:12:50 2011
New Revision: 219287
URL: http://svn.freebsd.org/changeset/base/219287
Log:
Upgrade the firmware on the card automatically if a better version is
available. Downgrade only for a major version mismatch.
MFC after: 1 week
Modified:
head/sys/dev/cxgbe/common/common.h
head/sys/dev/cxgbe/t4_main.c
Modified: head/sys/dev/cxgbe/common/common.h
==============================================================================
--- head/sys/dev/cxgbe/common/common.h Sat Mar 5 03:06:38 2011 (r219286)
+++ head/sys/dev/cxgbe/common/common.h Sat Mar 5 03:12:50 2011 (r219287)
@@ -53,8 +53,8 @@ enum {
};
#define FW_VERSION_MAJOR 1
-#define FW_VERSION_MINOR 2
-#define FW_VERSION_MICRO 65
+#define FW_VERSION_MINOR 3
+#define FW_VERSION_MICRO 0
struct port_stats {
u64 tx_octets; /* total # of octets in good frames */
Modified: head/sys/dev/cxgbe/t4_main.c
==============================================================================
--- head/sys/dev/cxgbe/t4_main.c Sat Mar 5 03:06:38 2011 (r219286)
+++ head/sys/dev/cxgbe/t4_main.c Sat Mar 5 03:12:50 2011 (r219287)
@@ -1256,28 +1256,69 @@ prep_firmware(struct adapter *sc)
/* Check firmware version and install a different one if necessary */
rc = t4_check_fw_version(sc);
if (rc != 0 || force_firmware_install) {
+ uint32_t v = 0;
fw = firmware_get(T4_FWNAME);
- if (fw == NULL) {
- device_printf(sc->dev,
- "Could not find firmware image %s\n", T4_FWNAME);
- return (ENOENT);
+ if (fw != NULL) {
+ const struct fw_hdr *hdr = (const void *)fw->data;
+
+ v = ntohl(hdr->fw_ver);
+
+ /*
+ * The firmware module will not be used if it isn't the
+ * same major version as what the driver was compiled
+ * with. This check trumps force_firmware_install.
+ */
+ if (G_FW_HDR_FW_VER_MAJOR(v) != FW_VERSION_MAJOR) {
+ device_printf(sc->dev,
+ "Found firmware image but version %d "
+ "can not be used with this driver (%d)\n",
+ G_FW_HDR_FW_VER_MAJOR(v), FW_VERSION_MAJOR);
+
+ firmware_put(fw, FIRMWARE_UNLOAD);
+ fw = NULL;
+ }
}
- device_printf(sc->dev,
- "installing firmware %d.%d.%d on card.\n",
- FW_VERSION_MAJOR, FW_VERSION_MINOR, FW_VERSION_MICRO);
- rc = -t4_load_fw(sc, fw->data, fw->datasize);
- if (rc != 0) {
+ if (fw == NULL && (rc < 0 || force_firmware_install)) {
+ device_printf(sc->dev, "No usable firmware. "
+ "card has %d.%d.%d, driver compiled with %d.%d.%d, "
+ "force_firmware_install%s set",
+ G_FW_HDR_FW_VER_MAJOR(sc->params.fw_vers),
+ G_FW_HDR_FW_VER_MINOR(sc->params.fw_vers),
+ G_FW_HDR_FW_VER_MICRO(sc->params.fw_vers),
+ FW_VERSION_MAJOR, FW_VERSION_MINOR,
+ FW_VERSION_MICRO,
+ force_firmware_install ? "" : " not");
+ return (EAGAIN);
+ }
+
+ /*
+ * Always upgrade, even for minor/micro/build mismatches.
+ * Downgrade only for a major version mismatch or if
+ * force_firmware_install was specified.
+ */
+ if (fw != NULL && (rc < 0 || force_firmware_install ||
+ v > sc->params.fw_vers)) {
device_printf(sc->dev,
- "failed to install firmware: %d\n", rc);
- return (rc);
- } else {
- t4_get_fw_version(sc, &sc->params.fw_vers);
- t4_get_tp_version(sc, &sc->params.tp_vers);
+ "installing firmware %d.%d.%d.%d on card.\n",
+ G_FW_HDR_FW_VER_MAJOR(v), G_FW_HDR_FW_VER_MINOR(v),
+ G_FW_HDR_FW_VER_MICRO(v), G_FW_HDR_FW_VER_BUILD(v));
+
+ rc = -t4_load_fw(sc, fw->data, fw->datasize);
+ if (rc != 0) {
+ device_printf(sc->dev,
+ "failed to install firmware: %d\n", rc);
+ firmware_put(fw, FIRMWARE_UNLOAD);
+ return (rc);
+ } else {
+ /* refresh */
+ (void) t4_check_fw_version(sc);
+ }
}
- firmware_put(fw, FIRMWARE_UNLOAD);
+ if (fw != NULL)
+ firmware_put(fw, FIRMWARE_UNLOAD);
}
/* Contact firmware, request master */
More information about the svn-src-head
mailing list