xref: /onnv-gate/usr/src/cmd/fwflash/plugins/vendor/tavor-MELLANOX.c (revision 12472:c0d938f047b6)
19517SBill.Taylor@Sun.COM /*
29517SBill.Taylor@Sun.COM  * CDDL HEADER START
39517SBill.Taylor@Sun.COM  *
49517SBill.Taylor@Sun.COM  * The contents of this file are subject to the terms of the
59517SBill.Taylor@Sun.COM  * Common Development and Distribution License (the "License").
69517SBill.Taylor@Sun.COM  * You may not use this file except in compliance with the License.
79517SBill.Taylor@Sun.COM  *
89517SBill.Taylor@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99517SBill.Taylor@Sun.COM  * or http://www.opensolaris.org/os/licensing.
109517SBill.Taylor@Sun.COM  * See the License for the specific language governing permissions
119517SBill.Taylor@Sun.COM  * and limitations under the License.
129517SBill.Taylor@Sun.COM  *
139517SBill.Taylor@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
149517SBill.Taylor@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
159517SBill.Taylor@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
169517SBill.Taylor@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
179517SBill.Taylor@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
189517SBill.Taylor@Sun.COM  *
199517SBill.Taylor@Sun.COM  * CDDL HEADER END
209517SBill.Taylor@Sun.COM  */
219517SBill.Taylor@Sun.COM 
229517SBill.Taylor@Sun.COM /*
23*12472SShantkumar.Hiremath@Sun.COM  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
249517SBill.Taylor@Sun.COM  */
259517SBill.Taylor@Sun.COM 
269517SBill.Taylor@Sun.COM /*
279517SBill.Taylor@Sun.COM  * Mellanox firmware image verification plugin
289517SBill.Taylor@Sun.COM  */
299517SBill.Taylor@Sun.COM 
309517SBill.Taylor@Sun.COM 
319517SBill.Taylor@Sun.COM #include <stdio.h>
329517SBill.Taylor@Sun.COM #include <stdlib.h>
339517SBill.Taylor@Sun.COM #include <unistd.h>
349517SBill.Taylor@Sun.COM #include <sys/types.h>
359517SBill.Taylor@Sun.COM #include <sys/stat.h>
369517SBill.Taylor@Sun.COM #include <sys/sysmacros.h>
379517SBill.Taylor@Sun.COM #include <fcntl.h>
389517SBill.Taylor@Sun.COM #include <sys/condvar.h>
399517SBill.Taylor@Sun.COM #include <string.h>
409517SBill.Taylor@Sun.COM #include <strings.h>
419517SBill.Taylor@Sun.COM 
429517SBill.Taylor@Sun.COM #include <sys/byteorder.h>
439517SBill.Taylor@Sun.COM 
449517SBill.Taylor@Sun.COM #include <libintl.h> /* for gettext(3c) */
459517SBill.Taylor@Sun.COM 
469517SBill.Taylor@Sun.COM #include <fwflash/fwflash.h>
479517SBill.Taylor@Sun.COM #include "../hdrs/MELLANOX.h"
489517SBill.Taylor@Sun.COM #include "../hdrs/tavor_ib.h"
499517SBill.Taylor@Sun.COM 
509517SBill.Taylor@Sun.COM char vendor[] = "MELLANOX\0";
519517SBill.Taylor@Sun.COM 
529517SBill.Taylor@Sun.COM extern int errno;
539517SBill.Taylor@Sun.COM extern struct vrfyplugin *verifier;
549517SBill.Taylor@Sun.COM 
559517SBill.Taylor@Sun.COM 
569517SBill.Taylor@Sun.COM /* required functions for this plugin */
579517SBill.Taylor@Sun.COM int vendorvrfy(struct devicelist *devicenode);
589517SBill.Taylor@Sun.COM 
599517SBill.Taylor@Sun.COM 
609517SBill.Taylor@Sun.COM /* helper functions */
619517SBill.Taylor@Sun.COM static int check_guid_ptr(uint8_t *data);
629517SBill.Taylor@Sun.COM 
639517SBill.Taylor@Sun.COM 
649517SBill.Taylor@Sun.COM int
vendorvrfy(struct devicelist * devicenode)659517SBill.Taylor@Sun.COM vendorvrfy(struct devicelist *devicenode)
669517SBill.Taylor@Sun.COM {
679517SBill.Taylor@Sun.COM 	struct ib_encap_ident	*encap;
689517SBill.Taylor@Sun.COM 	uint32_t	sector_sz;
699517SBill.Taylor@Sun.COM 	int		*firmware;
709517SBill.Taylor@Sun.COM 	uint32_t	vp_fia, vs_fia;
719517SBill.Taylor@Sun.COM 	uint32_t	vp_imginfo, vs_imginfo;
729517SBill.Taylor@Sun.COM 	struct mlx_xps	*vps;
739517SBill.Taylor@Sun.COM 	uint8_t		*vfi;
749517SBill.Taylor@Sun.COM 	int		i = 0, a, b, c, d;
759517SBill.Taylor@Sun.COM 	char		temppsid[17];
769517SBill.Taylor@Sun.COM 	char		rawpsid[16];
7710618SShantkumar.Hiremath@Sun.COM 	int		offset;
789517SBill.Taylor@Sun.COM 
799517SBill.Taylor@Sun.COM 	encap = (struct ib_encap_ident *)devicenode->ident->encap_ident;
809517SBill.Taylor@Sun.COM 
819517SBill.Taylor@Sun.COM 	/*
829517SBill.Taylor@Sun.COM 	 * NOTE that since verifier->fwimage is an array of ints,
839517SBill.Taylor@Sun.COM 	 * we have to divide our actual desired number by 4 to get
849517SBill.Taylor@Sun.COM 	 * the right data.
859517SBill.Taylor@Sun.COM 	 */
869517SBill.Taylor@Sun.COM 	firmware = verifier->fwimage;
879517SBill.Taylor@Sun.COM 
8810618SShantkumar.Hiremath@Sun.COM 	/*
8910618SShantkumar.Hiremath@Sun.COM 	 * The actual location of log2_sector_sz can be calculated
9010618SShantkumar.Hiremath@Sun.COM 	 * by adding 0x32 to the value that is written in the
9110618SShantkumar.Hiremath@Sun.COM 	 * log2_sector_sz_ptr field.  The log2_sector_sz_ptr is located
9210618SShantkumar.Hiremath@Sun.COM 	 * at 0x16 byte offset in Invariant Sector.
9310618SShantkumar.Hiremath@Sun.COM 	 */
9410618SShantkumar.Hiremath@Sun.COM 	offset = FLASH_IS_SECTOR_SIZE_OFFSET +
9510618SShantkumar.Hiremath@Sun.COM 	    MLXSWAPBITS32(firmware[FLASH_IS_SECT_SIZE_PTR/4]);
9610618SShantkumar.Hiremath@Sun.COM 
9710618SShantkumar.Hiremath@Sun.COM 	sector_sz = 1 << MLXSWAPBITS32(firmware[offset/4]);
989517SBill.Taylor@Sun.COM 
999517SBill.Taylor@Sun.COM 	if (sector_sz != encap->sector_sz) {
1009517SBill.Taylor@Sun.COM 		logmsg(MSG_ERROR,
1019517SBill.Taylor@Sun.COM 		    gettext("%s firmware image verifier: "
10210618SShantkumar.Hiremath@Sun.COM 		    "Invariant Sector is invalid\n"), verifier->vendor);
10310618SShantkumar.Hiremath@Sun.COM 		logmsg(MSG_ERROR, gettext("Mis-match in sector size: "
10410618SShantkumar.Hiremath@Sun.COM 		    "device's 0x%X file 0x%X\n"), encap->sector_sz, sector_sz);
10510618SShantkumar.Hiremath@Sun.COM 		logmsg(MSG_ERROR, gettext("Firmware image file is not "
10610618SShantkumar.Hiremath@Sun.COM 		    "appropriate for this device.\n"));
1079517SBill.Taylor@Sun.COM 		/* this is fatal */
1089517SBill.Taylor@Sun.COM 		return (FWFLASH_FAILURE);
1099517SBill.Taylor@Sun.COM 	}
1109517SBill.Taylor@Sun.COM 
1119517SBill.Taylor@Sun.COM 	/* now verify primary pointer sector */
1129517SBill.Taylor@Sun.COM 	if ((vps = calloc(1, sizeof (struct mlx_xps))) == NULL) {
1139517SBill.Taylor@Sun.COM 		logmsg(MSG_ERROR,
1149517SBill.Taylor@Sun.COM 		    gettext("%s firmware image verifier: "
1159517SBill.Taylor@Sun.COM 		    "Unable to allocate memory for Primary Pointer "
11610618SShantkumar.Hiremath@Sun.COM 		    "Sector verification\n"), verifier->vendor);
1179517SBill.Taylor@Sun.COM 		return (FWFLASH_FAILURE);
1189517SBill.Taylor@Sun.COM 	}
1199517SBill.Taylor@Sun.COM 	bcopy(&firmware[sector_sz / 4], vps, sizeof (struct mlx_xps));
1209517SBill.Taylor@Sun.COM 	if ((MLXSWAPBITS32(vps->signature) != FLASH_PS_SIGNATURE) ||
1219517SBill.Taylor@Sun.COM 	    (vps->xpsresv3 != 0)) {
1229517SBill.Taylor@Sun.COM 		logmsg(MSG_ERROR,
1239517SBill.Taylor@Sun.COM 		    gettext("%s firmware image verifier: "
1249517SBill.Taylor@Sun.COM 		    "Primary Pointer Sector is invalid\n"),
1259517SBill.Taylor@Sun.COM 		    verifier->vendor);
1269517SBill.Taylor@Sun.COM 	}
1279517SBill.Taylor@Sun.COM 	vp_fia = MLXSWAPBITS32(vps->fia);
1289517SBill.Taylor@Sun.COM 
1299517SBill.Taylor@Sun.COM 	/*
1309517SBill.Taylor@Sun.COM 	 * A slight diversion - check the PSID in the last
1319517SBill.Taylor@Sun.COM 	 * 16 bytes of the first 256bytes in the xPS sectors.
1329517SBill.Taylor@Sun.COM 	 * This will give us our part number to match. If the
1339517SBill.Taylor@Sun.COM 	 * part number in the image doesn't match the part number
1349517SBill.Taylor@Sun.COM 	 * in the encap_ident info (and pn_len > 0) then we reject
1359517SBill.Taylor@Sun.COM 	 * this image as being incompatible with the HCA.
1369517SBill.Taylor@Sun.COM 	 *
1379517SBill.Taylor@Sun.COM 	 * In this bit we're only checking the info.mlx_psid field
1389517SBill.Taylor@Sun.COM 	 * of the primary image in the on-disk image. If that's
1399517SBill.Taylor@Sun.COM 	 * invalid we reject the image.
1409517SBill.Taylor@Sun.COM 	 */
1419517SBill.Taylor@Sun.COM 
14210618SShantkumar.Hiremath@Sun.COM 	bzero(temppsid, 17);
14310618SShantkumar.Hiremath@Sun.COM 	bcopy(vps->vsdpsid+0xd0, &rawpsid, 16);
1449517SBill.Taylor@Sun.COM 
14510618SShantkumar.Hiremath@Sun.COM 	for (i = 0; i < 16; i += 4) {
14610618SShantkumar.Hiremath@Sun.COM 		temppsid[i]   = rawpsid[i+3];
14710618SShantkumar.Hiremath@Sun.COM 		temppsid[i+1] = rawpsid[i+2];
14810618SShantkumar.Hiremath@Sun.COM 		temppsid[i+2] = rawpsid[i+1];
14910618SShantkumar.Hiremath@Sun.COM 		temppsid[i+3] = rawpsid[i];
15010618SShantkumar.Hiremath@Sun.COM 	}
15110618SShantkumar.Hiremath@Sun.COM 	logmsg(MSG_INFO,
15210618SShantkumar.Hiremath@Sun.COM 	    "tavor: have raw '%s', want munged '%s'\n",
15310618SShantkumar.Hiremath@Sun.COM 	    rawpsid, temppsid);
15410618SShantkumar.Hiremath@Sun.COM 	logmsg(MSG_INFO, "tavor_vrfy: PSID file '%s' HCA's PSID '%s'\n",
15510618SShantkumar.Hiremath@Sun.COM 	    (temppsid != NULL) ? temppsid : "(null)",
15610618SShantkumar.Hiremath@Sun.COM 	    (encap->info.mlx_psid != NULL) ? encap->info.mlx_psid : "(null)");
15710618SShantkumar.Hiremath@Sun.COM 
15810618SShantkumar.Hiremath@Sun.COM 	if (encap->info.mlx_psid != NULL) {
15910618SShantkumar.Hiremath@Sun.COM 		int resp;
1609517SBill.Taylor@Sun.COM 		if (strncmp(encap->info.mlx_psid, temppsid, 16) != 0) {
1619517SBill.Taylor@Sun.COM 			logmsg(MSG_ERROR,
1629517SBill.Taylor@Sun.COM 			    gettext("%s firmware image verifier: "
1639517SBill.Taylor@Sun.COM 			    "firmware image file %s is not appropriate "
16410618SShantkumar.Hiremath@Sun.COM 			    "for device "
1659517SBill.Taylor@Sun.COM 			    "%s (PSID file %s vs PSID device %s)\n"),
1669517SBill.Taylor@Sun.COM 			    verifier->vendor, verifier->imgfile,
16710618SShantkumar.Hiremath@Sun.COM 			    devicenode->drvname,
16810618SShantkumar.Hiremath@Sun.COM 			    ((temppsid != NULL) ? temppsid : "(null)"),
16910618SShantkumar.Hiremath@Sun.COM 			    encap->info.mlx_psid);
1709517SBill.Taylor@Sun.COM 
17110618SShantkumar.Hiremath@Sun.COM 			logmsg(MSG_ERROR,
17210618SShantkumar.Hiremath@Sun.COM 			    gettext("Do you want to continue? (Y/N): "));
17310618SShantkumar.Hiremath@Sun.COM 			(void) fflush(stdin);
17410618SShantkumar.Hiremath@Sun.COM 			resp = getchar();
17510618SShantkumar.Hiremath@Sun.COM 			if (resp != 'Y' && resp != 'y') {
17610618SShantkumar.Hiremath@Sun.COM 				free(vps);
17710618SShantkumar.Hiremath@Sun.COM 				logmsg(MSG_ERROR, gettext("Not proceeding with "
17810869SXin.Chen@Sun.COM 				    "flash operation of %s on %s\n"),
17910618SShantkumar.Hiremath@Sun.COM 				    verifier->imgfile, devicenode->drvname);
18010618SShantkumar.Hiremath@Sun.COM 				return (FWFLASH_FAILURE);
18110618SShantkumar.Hiremath@Sun.COM 			}
1829517SBill.Taylor@Sun.COM 		} else {
1839517SBill.Taylor@Sun.COM 			logmsg(MSG_INFO,
1849517SBill.Taylor@Sun.COM 			    "%s firmware image verifier: HCA PSID (%s) "
1859517SBill.Taylor@Sun.COM 			    "matches firmware image %s's PSID\n",
1869517SBill.Taylor@Sun.COM 			    verifier->vendor,
1879517SBill.Taylor@Sun.COM 			    encap->info.mlx_psid,
1889517SBill.Taylor@Sun.COM 			    verifier->imgfile);
1899517SBill.Taylor@Sun.COM 		}
1909517SBill.Taylor@Sun.COM 	}
1919517SBill.Taylor@Sun.COM 
1929517SBill.Taylor@Sun.COM 
1939517SBill.Taylor@Sun.COM 	/* now verify secondary pointer sector */
1949517SBill.Taylor@Sun.COM 	bzero(vps, sizeof (struct mlx_xps));
1959517SBill.Taylor@Sun.COM 
1969517SBill.Taylor@Sun.COM 	bcopy(&firmware[sector_sz / 2], vps, sizeof (struct mlx_xps));
1979517SBill.Taylor@Sun.COM 	if ((MLXSWAPBITS32(vps->signature) != FLASH_PS_SIGNATURE) ||
1989517SBill.Taylor@Sun.COM 	    (vps->xpsresv3 != 0)) {
1999517SBill.Taylor@Sun.COM 		logmsg(MSG_ERROR,
2009517SBill.Taylor@Sun.COM 		    gettext("%s firmware image verifier: "
2019517SBill.Taylor@Sun.COM 		    "Secondary Pointer Sector is invalid\n"),
2029517SBill.Taylor@Sun.COM 		    verifier->vendor);
2039517SBill.Taylor@Sun.COM 	}
2049517SBill.Taylor@Sun.COM 	vs_fia = MLXSWAPBITS32(vps->fia);
2059517SBill.Taylor@Sun.COM 
2069517SBill.Taylor@Sun.COM 	(void) free(vps);
2079517SBill.Taylor@Sun.COM 
2089517SBill.Taylor@Sun.COM 	if ((vfi = calloc(1, sector_sz)) == NULL) {
2099517SBill.Taylor@Sun.COM 		logmsg(MSG_ERROR,
2109517SBill.Taylor@Sun.COM 		    gettext("%s firmware image verifier: "
2119517SBill.Taylor@Sun.COM 		    "Unable to allocate space for Primary "
2129517SBill.Taylor@Sun.COM 		    "Firmware Image verification\n"),
2139517SBill.Taylor@Sun.COM 		    verifier->vendor);
2149517SBill.Taylor@Sun.COM 		return (FWFLASH_FAILURE);
2159517SBill.Taylor@Sun.COM 	}
2169517SBill.Taylor@Sun.COM 	bcopy(&firmware[vp_fia / 4], vfi, sector_sz);
2179517SBill.Taylor@Sun.COM 	bcopy(&vfi[XFI_IMGINFO_OFFSET], &i, 4);
2189517SBill.Taylor@Sun.COM 	vp_imginfo = MLXSWAPBITS32(i);
2199517SBill.Taylor@Sun.COM 
2209517SBill.Taylor@Sun.COM 	/* for readability only */
2219517SBill.Taylor@Sun.COM 	a = (vp_imginfo & 0xff000000) >> 24;
2229517SBill.Taylor@Sun.COM 	b = (vp_imginfo & 0x00ff0000) >> 16;
2239517SBill.Taylor@Sun.COM 	c = (vp_imginfo & 0x0000ff00) >> 8;
2249517SBill.Taylor@Sun.COM 	d = (vp_imginfo & 0x000000ff);
2259517SBill.Taylor@Sun.COM 
2269517SBill.Taylor@Sun.COM 	/*
2279517SBill.Taylor@Sun.COM 	 * It appears to be the case (empirically) that this particular
2289517SBill.Taylor@Sun.COM 	 * check condition for ImageInfoPtr doesn't hold for A1 firmware
2299517SBill.Taylor@Sun.COM 	 * images. So if the ((a+b+c+d)%0x100) fails, don't worry unless
2309517SBill.Taylor@Sun.COM 	 * the contents of the GUID section do not match the Mellanox
2319517SBill.Taylor@Sun.COM 	 * default GUIDs 2c9000100d05[0123]. The A2++ images also have
2329517SBill.Taylor@Sun.COM 	 * these default GUIDS.
2339517SBill.Taylor@Sun.COM 	 *
2349517SBill.Taylor@Sun.COM 	 * Unfortunately we can't depend on the hwrev field of the image's
2359517SBill.Taylor@Sun.COM 	 * Invariant Sector for another level of confirmation, since A2++
2369517SBill.Taylor@Sun.COM 	 * images seem to have that field set to 0xa1 as well as the A1
2379517SBill.Taylor@Sun.COM 	 * images. Annoying!
2389517SBill.Taylor@Sun.COM 	 */
2399517SBill.Taylor@Sun.COM 
2409517SBill.Taylor@Sun.COM 	if ((((a+b+c+d) % 0x100) == 0) &&
2419517SBill.Taylor@Sun.COM 	    (vp_imginfo != 0x00000000)) {
2429517SBill.Taylor@Sun.COM 		logmsg(MSG_INFO,
2439517SBill.Taylor@Sun.COM 		    "%s firmware image verifier: "
2449517SBill.Taylor@Sun.COM 		    "Primary Firmware Image Info pointer is valid\n",
2459517SBill.Taylor@Sun.COM 		    verifier->vendor);
2469517SBill.Taylor@Sun.COM 	} else {
2479517SBill.Taylor@Sun.COM 
24810618SShantkumar.Hiremath@Sun.COM 		logmsg(MSG_INFO,
2499517SBill.Taylor@Sun.COM 		    gettext("%s firmware image verifier: "
2509517SBill.Taylor@Sun.COM 		    "Primary Firmware Image Info pointer is invalid "
2519517SBill.Taylor@Sun.COM 		    "(0x%04x)\nChecking GUID section.....\n"),
2529517SBill.Taylor@Sun.COM 		    verifier->vendor, vp_imginfo);
2539517SBill.Taylor@Sun.COM 
2549517SBill.Taylor@Sun.COM 		if (check_guid_ptr(vfi) == FWFLASH_FAILURE) {
25510618SShantkumar.Hiremath@Sun.COM 			logmsg(MSG_INFO,
2569517SBill.Taylor@Sun.COM 			    gettext("%s firmware image verifier: "
2579517SBill.Taylor@Sun.COM 			    "Primary Firmware Image GUID section "
2589517SBill.Taylor@Sun.COM 			    "is invalid\n"),
2599517SBill.Taylor@Sun.COM 			    verifier->vendor);
2609517SBill.Taylor@Sun.COM 			i = 1;
2619517SBill.Taylor@Sun.COM 		} else {
2629517SBill.Taylor@Sun.COM 			logmsg(MSG_INFO,
2639517SBill.Taylor@Sun.COM 			    "%s firmware image verifier: "
2649517SBill.Taylor@Sun.COM 			    "Primary GUID section is ok\n",
2659517SBill.Taylor@Sun.COM 			    verifier->vendor);
2669517SBill.Taylor@Sun.COM 		}
2679517SBill.Taylor@Sun.COM 
2689517SBill.Taylor@Sun.COM 	}
2699517SBill.Taylor@Sun.COM 
2709517SBill.Taylor@Sun.COM 	bzero(vfi, sector_sz);
2719517SBill.Taylor@Sun.COM 	bcopy(&firmware[vs_fia / 4], vfi, sector_sz);
2729517SBill.Taylor@Sun.COM 
2739517SBill.Taylor@Sun.COM 	bcopy(&vfi[XFI_IMGINFO_OFFSET], &i, 4);
2749517SBill.Taylor@Sun.COM 	vs_imginfo = MLXSWAPBITS32(i);
2759517SBill.Taylor@Sun.COM 
2769517SBill.Taylor@Sun.COM 	/* for readability only */
2779517SBill.Taylor@Sun.COM 	a = (vs_imginfo & 0xff000000) >> 24;
2789517SBill.Taylor@Sun.COM 	b = (vs_imginfo & 0x00ff0000) >> 16;
2799517SBill.Taylor@Sun.COM 	c = (vs_imginfo & 0x0000ff00) >> 8;
2809517SBill.Taylor@Sun.COM 	d = (vs_imginfo & 0x000000ff);
2819517SBill.Taylor@Sun.COM 
2829517SBill.Taylor@Sun.COM 	if ((((a+b+c+d) % 0x100) == 0) &&
2839517SBill.Taylor@Sun.COM 	    (vs_imginfo != 0x00000000)) {
2849517SBill.Taylor@Sun.COM 		logmsg(MSG_INFO,
2859517SBill.Taylor@Sun.COM 		    "%s firmware image verifier: "
2869517SBill.Taylor@Sun.COM 		    "Secondary Firmware Image Info pointer is valid\n",
2879517SBill.Taylor@Sun.COM 		    verifier->vendor);
2889517SBill.Taylor@Sun.COM 	} else {
28910618SShantkumar.Hiremath@Sun.COM 		logmsg(MSG_INFO,
2909517SBill.Taylor@Sun.COM 		    gettext("%s firmware image verifier: "
2919517SBill.Taylor@Sun.COM 		    "Secondary Firmware Image Info pointer is invalid "
2929517SBill.Taylor@Sun.COM 		    "(0x%04x)\nChecking GUID section.....\n"),
2939517SBill.Taylor@Sun.COM 		    verifier->vendor, vp_imginfo);
2949517SBill.Taylor@Sun.COM 
2959517SBill.Taylor@Sun.COM 		if (check_guid_ptr(vfi) == FWFLASH_FAILURE) {
29610618SShantkumar.Hiremath@Sun.COM 			logmsg(MSG_INFO,
2979517SBill.Taylor@Sun.COM 			    gettext("%s firmware image verifier: "
2989517SBill.Taylor@Sun.COM 			    "Secondary Firmware Image GUID section "
2999517SBill.Taylor@Sun.COM 			    "is invalid\n"),
3009517SBill.Taylor@Sun.COM 			    verifier->vendor);
3019517SBill.Taylor@Sun.COM 			i++;
3029517SBill.Taylor@Sun.COM 		}
3039517SBill.Taylor@Sun.COM 	}
3049517SBill.Taylor@Sun.COM 
3059517SBill.Taylor@Sun.COM 	free(vfi);
3069517SBill.Taylor@Sun.COM 
30710618SShantkumar.Hiremath@Sun.COM 	if (i == 2)
30810618SShantkumar.Hiremath@Sun.COM 		logmsg(MSG_WARN, gettext("%s firmware image verifier: "
30910618SShantkumar.Hiremath@Sun.COM 		    "FAILED\n"), verifier->vendor);
3109517SBill.Taylor@Sun.COM 
3119517SBill.Taylor@Sun.COM 	return ((i == 2) ? (FWFLASH_FAILURE) : (FWFLASH_SUCCESS));
3129517SBill.Taylor@Sun.COM }
3139517SBill.Taylor@Sun.COM 
3149517SBill.Taylor@Sun.COM 
3159517SBill.Taylor@Sun.COM /*
3169517SBill.Taylor@Sun.COM  * Very simple function - we're given an array of bytes,
3179517SBill.Taylor@Sun.COM  * we know that we need to read the value at offset FLASH_GUID_PTR
3189517SBill.Taylor@Sun.COM  * and jump to that location to read 4x uint64_t of (hopefully)
3199517SBill.Taylor@Sun.COM  * GUID data. If we can read that data, and it matches the default
3209517SBill.Taylor@Sun.COM  * Mellanox GUIDs, then we return success. We need all 4 default
3219517SBill.Taylor@Sun.COM  * GUIDs to match otherwise we return failure.
3229517SBill.Taylor@Sun.COM  */
3239517SBill.Taylor@Sun.COM static int
check_guid_ptr(uint8_t * data)3249517SBill.Taylor@Sun.COM check_guid_ptr(uint8_t *data)
3259517SBill.Taylor@Sun.COM {
3269517SBill.Taylor@Sun.COM 	struct mlx_xfi	xfisect;
3279517SBill.Taylor@Sun.COM 	struct mlx_guid_sect	guidsect;
3289517SBill.Taylor@Sun.COM 
3299517SBill.Taylor@Sun.COM 	bcopy(data, &xfisect, sizeof (xfisect));
3309517SBill.Taylor@Sun.COM 	bcopy(&data[MLXSWAPBITS32(xfisect.nguidptr) - 16], &guidsect,
3319517SBill.Taylor@Sun.COM 	    GUIDSECTION_SZ);
3329517SBill.Taylor@Sun.COM 
3339517SBill.Taylor@Sun.COM 	logmsg(MSG_INFO, "nodeguid:  %0llx\n",
3349517SBill.Taylor@Sun.COM 	    MLXSWAPBITS64(guidsect.nodeguid));
3359517SBill.Taylor@Sun.COM 	logmsg(MSG_INFO, "port1guid: %0llx\n",
3369517SBill.Taylor@Sun.COM 	    MLXSWAPBITS64(guidsect.port1guid));
3379517SBill.Taylor@Sun.COM 	logmsg(MSG_INFO, "port2guid: %0llx\n",
3389517SBill.Taylor@Sun.COM 	    MLXSWAPBITS64(guidsect.port2guid));
3399517SBill.Taylor@Sun.COM 	logmsg(MSG_INFO, "sysimguid: %0llx\n",
3409517SBill.Taylor@Sun.COM 	    MLXSWAPBITS64(guidsect.sysimguid));
3419517SBill.Taylor@Sun.COM 
3429517SBill.Taylor@Sun.COM 	if ((MLXSWAPBITS64(guidsect.nodeguid) == MLX_DEFAULT_NODE_GUID) &&
3439517SBill.Taylor@Sun.COM 	    (MLXSWAPBITS64(guidsect.port1guid) == MLX_DEFAULT_P1_GUID) &&
3449517SBill.Taylor@Sun.COM 	    (MLXSWAPBITS64(guidsect.port2guid) == MLX_DEFAULT_P2_GUID) &&
3459517SBill.Taylor@Sun.COM 	    ((MLXSWAPBITS64(guidsect.sysimguid) == MLX_DEFAULT_SYSIMG_GUID) ||
3469517SBill.Taylor@Sun.COM 	    (MLXSWAPBITS64(guidsect.sysimguid) == MLX_DEFAULT_NODE_GUID)) ||
3479517SBill.Taylor@Sun.COM 	    ((((MLXSWAPBITS64(guidsect.nodeguid) & HIGHBITS64) >> 40)
3489517SBill.Taylor@Sun.COM 	    == MLX_OUI) ||
3499517SBill.Taylor@Sun.COM 	    (((MLXSWAPBITS64(guidsect.port1guid) & HIGHBITS64) >> 40)
3509517SBill.Taylor@Sun.COM 	    == MLX_OUI) ||
3519517SBill.Taylor@Sun.COM 	    (((MLXSWAPBITS64(guidsect.port2guid) & HIGHBITS64) >> 40)
3529517SBill.Taylor@Sun.COM 	    == MLX_OUI) ||
3539517SBill.Taylor@Sun.COM 	    (((MLXSWAPBITS64(guidsect.sysimguid) & HIGHBITS64) >> 40)
3549517SBill.Taylor@Sun.COM 	    == MLX_OUI))) {
3559517SBill.Taylor@Sun.COM 		return (FWFLASH_SUCCESS);
3569517SBill.Taylor@Sun.COM 	} else {
3579517SBill.Taylor@Sun.COM 		return (FWFLASH_FAILURE);
3589517SBill.Taylor@Sun.COM 	}
3599517SBill.Taylor@Sun.COM }
360