6850828 fwflash: tavor plugin is broken for arbel memfull cards.
authorShantkumar Hiremath<Shantkumar.Hiremath@Sun.COM>
Wed, 23 Sep 2009 00:32:09 -0700
changeset 10618 0a7bd81cff1c
parent 10617 ae54b3d31f50
child 10619 bb631a61091f
6850828 fwflash: tavor plugin is broken for arbel memfull cards. 6881664 fwflash: hermon plugin terminates if HCA VPD data is not available.
usr/src/cmd/fwflash/plugins/transport/common/hermon.c
usr/src/cmd/fwflash/plugins/transport/common/tavor.c
usr/src/cmd/fwflash/plugins/vendor/hermon-MELLANOX.c
usr/src/cmd/fwflash/plugins/vendor/tavor-MELLANOX.c
--- a/usr/src/cmd/fwflash/plugins/transport/common/hermon.c	Wed Sep 23 10:29:53 2009 +0800
+++ b/usr/src/cmd/fwflash/plugins/transport/common/hermon.c	Wed Sep 23 00:32:09 2009 -0700
@@ -865,7 +865,7 @@
 	 * Until we find out otherwise, add it onto the end of the
 	 * firmware version details.
 	 */
-	snprintf(thisdev->ident->revid, MLX_VPR_REVLEN, "%d.%d.%04d",
+	snprintf(thisdev->ident->revid, MLX_VPR_REVLEN, "%d.%d.%03d",
 	    manuf->hwfw_img_info.fw_rev.major,
 	    manuf->hwfw_img_info.fw_rev.minor,
 	    manuf->hwfw_img_info.fw_rev.subminor);
@@ -1732,7 +1732,7 @@
 			img_info->fw_rev.subminor =
 			    tmp & CNX_MASK_FW_VER_SUBMIN;
 
-			logmsg(MSG_INFO, "FW_VER: %d.%d.%d\n",
+			logmsg(MSG_INFO, "FW_VER: %d.%d.%03d\n",
 			    img_info->fw_rev.major, img_info->fw_rev.minor,
 			    img_info->fw_rev.subminor);
 			break;
--- a/usr/src/cmd/fwflash/plugins/transport/common/tavor.c	Wed Sep 23 10:29:53 2009 +0800
+++ b/usr/src/cmd/fwflash/plugins/transport/common/tavor.c	Wed Sep 23 00:32:09 2009 -0700
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -631,7 +631,7 @@
 		if ((newdev = calloc(1, sizeof (struct devicelist)))
 		    == NULL) {
 			logmsg(MSG_ERROR,
-			    gettext("%s identification function unable "
+			    gettext("tavor identification function: unable "
 			    "to allocate space for device entry\n"));
 			di_devfs_path_free(devpath);
 			return (rv);
@@ -852,6 +852,8 @@
 
 	thisdev->ident->encap_ident = manuf;
 
+	bzero(&init_ioctl, sizeof (tavor_flash_init_ioctl_t));
+	bzero(&cfi, sizeof (cfi_t));
 	/*
 	 * Inform driver that this command supports the Intel Extended
 	 * CFI command set.
@@ -897,7 +899,10 @@
 			return (FWFLASH_FAILURE);
 		}
 		/* set some defaults */
+		manuf->sector_sz = TAVOR_FLASH_SECTOR_SZ_DEFAULT;
 		manuf->device_sz = TAVOR_FLASH_DEVICE_SZ_DEFAULT;
+		logmsg(MSG_INFO, "tavor_identify: CMDSET is AMD, SectorSz "
+		    "are default \n");
 	} else {
 		if (manuf->cmd_set != TAVOR_FLASH_AMD_CMDSET &&
 		    manuf->cmd_set != TAVOR_FLASH_INTEL_CMDSET) {
@@ -911,9 +916,10 @@
 		manuf->sector_sz = ((cfi.cfi_char[0x30] << 8) |
 		    cfi.cfi_char[0x2F]) << 8;
 		manuf->device_sz = 0x1 << cfi.cfi_char[0x27];
+		logmsg(MSG_INFO, "tavor_identify: SectorSz is from CFI Data\n");
 	}
 
-	logmsg(MSG_INFO, "sector_sz: 0x%08x\ndevice_sz: 0x%08x\n",
+	logmsg(MSG_INFO, "tavor_identify: sector_sz: 0x%08x dev_sz: 0x%08x\n",
 	    manuf->sector_sz, manuf->device_sz);
 
 	manuf->state |= FWFLASH_IB_STATE_MMAP;
@@ -923,6 +929,10 @@
 	manuf->fw_rev.minor = init_ioctl.tf_fwrev.tfi_min;
 	manuf->fw_rev.subminor = init_ioctl.tf_fwrev.tfi_sub;
 
+	logmsg(MSG_INFO, "tavor_identify: pn_len %d hwpn %s \n",
+	    init_ioctl.tf_pn_len,
+	    (init_ioctl.tf_pn_len != 0) ? init_ioctl.tf_hwpn : "(null)");
+
 	if (((thisdev->ident->vid = calloc(1, MLX_VPR_VIDLEN + 1)) == NULL) ||
 	    ((thisdev->ident->revid = calloc(1, MLX_VPR_REVLEN + 1)) == NULL)) {
 
@@ -944,7 +954,7 @@
 	 * firmware version details.
 	 */
 
-	snprintf(thisdev->ident->revid, MLX_VPR_REVLEN, "%d.%d.%04d",
+	snprintf(thisdev->ident->revid, MLX_VPR_REVLEN, "%d.%d.%03d",
 	    manuf->fw_rev.major, manuf->fw_rev.minor,
 	    manuf->fw_rev.subminor);
 
@@ -1716,7 +1726,8 @@
 
 	if ((prisec != 1) && (prisec != 2)) {
 		logmsg(MSG_ERROR,
-		    "tavor: invalid image number requested (%d)\n");
+		    gettext("tavor: invalid image number requested (%d)\n"),
+		    prisec);
 		return (FWFLASH_FAILURE);
 	}
 
--- a/usr/src/cmd/fwflash/plugins/vendor/hermon-MELLANOX.c	Wed Sep 23 10:29:53 2009 +0800
+++ b/usr/src/cmd/fwflash/plugins/vendor/hermon-MELLANOX.c	Wed Sep 23 00:32:09 2009 -0700
@@ -108,6 +108,8 @@
 	}
 
 	if (handle->hwfw_match == 0) {
+		int resp;
+
 		if (handle->pn_len != 0) {
 			/* HW VPD exist and a mismatch was found */
 			logmsg(MSG_ERROR, gettext("hermon: Please verify that "
@@ -117,13 +119,22 @@
 			logmsg(MSG_ERROR, gettext("hermon: Unable to verify "
 			    "firmware is appropriate for the hardware\n"));
 		}
-		return (FWFLASH_FAILURE);
+		logmsg(MSG_ERROR, gettext("Do you want to continue? (Y/N): "));
+		(void) fflush(stdin);
+		resp = getchar();
+		if (resp != 'Y' && resp != 'y') {
+			logmsg(MSG_ERROR, gettext("Not proceeding with "
+			    "flash operation of %s on %s"),
+			    verifier->imgfile, devicenode->drvname);
+			return (FWFLASH_FAILURE);
+		}
+	} else {
+		logmsg(MSG_INFO, "%s firmware image verifier: HCA PSID (%s) "
+		    "matches firmware image %s's PSID\n", verifier->vendor,
+		    handle->info.mlx_psid, verifier->imgfile);
+
+		cnx_display_fwver(handle);
 	}
-	logmsg(MSG_INFO, "%s firmware image verifier: HCA PSID (%s) "
-	    "matches firmware image %s's PSID\n", verifier->vendor,
-	    handle->info.mlx_psid, verifier->imgfile);
-
-	cnx_display_fwver(handle);
 
 	return (FWFLASH_SUCCESS);
 }
@@ -171,12 +182,12 @@
 	logmsg(MSG_INFO, "hermon: verify: cnx_display_fwver\n");
 
 	(void) fprintf(stdout, gettext("  The current HCA firmware version "
-	    "is    : %d.%d.%04d\n"),
+	    "is    : %d.%d.%03d\n"),
 	    handle->hwfw_img_info.fw_rev.major,
 	    handle->hwfw_img_info.fw_rev.minor,
 	    handle->hwfw_img_info.fw_rev.subminor);
 	(void) fprintf(stdout, gettext("  Will be updated to HCA firmware "
-	    "ver of : %d.%d.%04d\n"),
+	    "ver of : %d.%d.%03d\n"),
 	    handle->file_img_info.fw_rev.major,
 	    handle->file_img_info.fw_rev.minor,
 	    handle->file_img_info.fw_rev.subminor);
--- a/usr/src/cmd/fwflash/plugins/vendor/tavor-MELLANOX.c	Wed Sep 23 10:29:53 2009 +0800
+++ b/usr/src/cmd/fwflash/plugins/vendor/tavor-MELLANOX.c	Wed Sep 23 00:32:09 2009 -0700
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -48,13 +48,10 @@
 #include "../hdrs/MELLANOX.h"
 #include "../hdrs/tavor_ib.h"
 
-
-
 char vendor[] = "MELLANOX\0";
 
 extern int errno;
 extern struct vrfyplugin *verifier;
-extern uint16_t crc16(uint8_t *image, uint32_t size);
 
 
 /* required functions for this plugin */
@@ -78,6 +75,7 @@
 	int		i = 0, a, b, c, d;
 	char		temppsid[17];
 	char		rawpsid[16];
+	int		offset;
 
 	encap = (struct ib_encap_ident *)devicenode->ident->encap_ident;
 
@@ -88,14 +86,25 @@
 	 */
 	firmware = verifier->fwimage;
 
-	/* sector_sz is stored as Log_2 of the real value */
-	sector_sz = 1 << MLXSWAPBITS32(firmware[FLASH_IS_SECTOR_SIZE_OFFSET/4]);
+	/*
+	 * The actual location of log2_sector_sz can be calculated
+	 * by adding 0x32 to the value that is written in the
+	 * log2_sector_sz_ptr field.  The log2_sector_sz_ptr is located
+	 * at 0x16 byte offset in Invariant Sector.
+	 */
+	offset = FLASH_IS_SECTOR_SIZE_OFFSET +
+	    MLXSWAPBITS32(firmware[FLASH_IS_SECT_SIZE_PTR/4]);
+
+	sector_sz = 1 << MLXSWAPBITS32(firmware[offset/4]);
 
 	if (sector_sz != encap->sector_sz) {
 		logmsg(MSG_ERROR,
 		    gettext("%s firmware image verifier: "
-		    "Invariant Sector is invalid\n"),
-		    verifier->vendor);
+		    "Invariant Sector is invalid\n"), verifier->vendor);
+		logmsg(MSG_ERROR, gettext("Mis-match in sector size: "
+		    "device's 0x%X file 0x%X\n"), encap->sector_sz, sector_sz);
+		logmsg(MSG_ERROR, gettext("Firmware image file is not "
+		    "appropriate for this device.\n"));
 		/* this is fatal */
 		return (FWFLASH_FAILURE);
 	}
@@ -105,7 +114,7 @@
 		logmsg(MSG_ERROR,
 		    gettext("%s firmware image verifier: "
 		    "Unable to allocate memory for Primary Pointer "
-		    "Sector verification\n"));
+		    "Sector verification\n"), verifier->vendor);
 		return (FWFLASH_FAILURE);
 	}
 	bcopy(&firmware[sector_sz / 4], vps, sizeof (struct mlx_xps));
@@ -131,35 +140,50 @@
 	 * invalid we reject the image.
 	 */
 
-	if (encap->info.mlx_psid != NULL) {
-		bzero(temppsid, 17);
-		bcopy(vps->vsdpsid+0xd0, &rawpsid, 16);
+	bzero(temppsid, 17);
+	bcopy(vps->vsdpsid+0xd0, &rawpsid, 16);
 
-#if !defined(_LITTLE_ENDIAN)
-		for (i = 0; i < 16; i += 4) {
-			temppsid[i]   = rawpsid[i+3];
-			temppsid[i+1] = rawpsid[i+2];
-			temppsid[i+2] = rawpsid[i+1];
-			temppsid[i+3] = rawpsid[i];
-		}
-		logmsg(MSG_INFO,
-		    "tavor: have raw '%s', want munged '%s'\n",
-		    rawpsid, temppsid);
+#if defined(_LITTLE_ENDIAN)
+	for (i = 0; i < 16; i += 4) {
+		temppsid[i]   = rawpsid[i+3];
+		temppsid[i+1] = rawpsid[i+2];
+		temppsid[i+2] = rawpsid[i+1];
+		temppsid[i+3] = rawpsid[i];
+	}
+	logmsg(MSG_INFO,
+	    "tavor: have raw '%s', want munged '%s'\n",
+	    rawpsid, temppsid);
 #else
-		bcopy(vps->vsdpsid+0xd0, &temppsid, 16);
+	bcopy(vps->vsdpsid+0xd0, &temppsid, 16);
 #endif
+	logmsg(MSG_INFO, "tavor_vrfy: PSID file '%s' HCA's PSID '%s'\n",
+	    (temppsid != NULL) ? temppsid : "(null)",
+	    (encap->info.mlx_psid != NULL) ? encap->info.mlx_psid : "(null)");
+
+	if (encap->info.mlx_psid != NULL) {
+		int resp;
 		if (strncmp(encap->info.mlx_psid, temppsid, 16) != 0) {
 			logmsg(MSG_ERROR,
 			    gettext("%s firmware image verifier: "
 			    "firmware image file %s is not appropriate "
-			    "for device\n"
+			    "for device "
 			    "%s (PSID file %s vs PSID device %s)\n"),
 			    verifier->vendor, verifier->imgfile,
-			    encap->info.mlx_psid,
-			    ((temppsid != NULL) ? temppsid : "(null)"));
+			    devicenode->drvname,
+			    ((temppsid != NULL) ? temppsid : "(null)"),
+			    encap->info.mlx_psid);
 
-			free(vps);
-			return (FWFLASH_FAILURE);
+			logmsg(MSG_ERROR,
+			    gettext("Do you want to continue? (Y/N): "));
+			(void) fflush(stdin);
+			resp = getchar();
+			if (resp != 'Y' && resp != 'y') {
+				free(vps);
+				logmsg(MSG_ERROR, gettext("Not proceeding with "
+				    "flash operation of %s on %s"),
+				    verifier->imgfile, devicenode->drvname);
+				return (FWFLASH_FAILURE);
+			}
 		} else {
 			logmsg(MSG_INFO,
 			    "%s firmware image verifier: HCA PSID (%s) "
@@ -226,14 +250,14 @@
 		    verifier->vendor);
 	} else {
 
-		logmsg(MSG_ERROR,
+		logmsg(MSG_INFO,
 		    gettext("%s firmware image verifier: "
 		    "Primary Firmware Image Info pointer is invalid "
 		    "(0x%04x)\nChecking GUID section.....\n"),
 		    verifier->vendor, vp_imginfo);
 
 		if (check_guid_ptr(vfi) == FWFLASH_FAILURE) {
-			logmsg(MSG_ERROR,
+			logmsg(MSG_INFO,
 			    gettext("%s firmware image verifier: "
 			    "Primary Firmware Image GUID section "
 			    "is invalid\n"),
@@ -267,14 +291,14 @@
 		    "Secondary Firmware Image Info pointer is valid\n",
 		    verifier->vendor);
 	} else {
-		logmsg(MSG_ERROR,
+		logmsg(MSG_INFO,
 		    gettext("%s firmware image verifier: "
 		    "Secondary Firmware Image Info pointer is invalid "
 		    "(0x%04x)\nChecking GUID section.....\n"),
 		    verifier->vendor, vp_imginfo);
 
 		if (check_guid_ptr(vfi) == FWFLASH_FAILURE) {
-			logmsg(MSG_ERROR,
+			logmsg(MSG_INFO,
 			    gettext("%s firmware image verifier: "
 			    "Secondary Firmware Image GUID section "
 			    "is invalid\n"),
@@ -285,6 +309,9 @@
 
 	free(vfi);
 
+	if (i == 2)
+		logmsg(MSG_WARN, gettext("%s firmware image verifier: "
+		    "FAILED\n"), verifier->vendor);
 
 	return ((i == 2) ? (FWFLASH_FAILURE) : (FWFLASH_SUCCESS));
 }