/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* ConnectX (hermon) firmware image verification plugin
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/sysmacros.h>
#include <fcntl.h>
#include <string.h>
#include <strings.h>
#include <sys/byteorder.h>
#include <libintl.h> /* for gettext(3c) */
#include "../hdrs/hermon_ib.h"
extern struct vrfyplugin *verifier;
/* required functions for this plugin */
/* helper functions */
static int cnx_check_guid_section();
int
{
if (CNX_I_CHECK_HANDLE(handle)) {
return (FWFLASH_FAILURE);
}
/*
* NOTE verifier->fwimage is where file is read to.
*/
"No magic pattern found in firmware file %s \n"),
return (FWFLASH_FAILURE);
}
if (cnx_check_guid_section() == FWFLASH_FAILURE) {
"Firmware Image GUID section is invalid\n",
}
/* Check Hardware Rev */
if (ver != 0) {
return (FWFLASH_FAILURE);
}
if (handle->hwfw_match == 0) {
int resp;
/* HW VPD exist and a mismatch was found */
"the firmware image is intended for use with this "
"hardware\n"));
} else {
"firmware is appropriate for the hardware\n"));
}
"flash operation of %s on %s \n"),
return (FWFLASH_FAILURE);
}
} else {
}
return (FWFLASH_SUCCESS);
}
static uint16_t
{
"first\n"));
return (1);
}
/* Read Flash HW Version */
CNX_HWVER_MASK) >> 24;
local_hwver == 0x20)) {
} else if (hwver != local_hwver) {
}
return (0);
}
static void
{
"is : %d.%d.%03d\n"),
"ver of : %d.%d.%03d\n"),
}
static uchar_t *
{
/* Get the image info pointer */
/* Get the image info size, a negative offset from the image info ptr */
ii_size =
/* size is in dwords--convert it to bytes */
ii_size *= 4;
/* Parse the image info section */
"section\n"));
return (NULL);
}
}
static void
int psid_size)
{
int i;
int no_match = 0;
/* verify fw matches the hardware */
/* already been verified */
return;
}
/* find the PSID from FW in the mlx table */
for (i = 0; i < MLX_MAX_ID; i++) {
/*
* Need this check here and the 'continue's below
* because there are some cards that have a
* 'new' part number but the same PSID value.
*/
break;
}
/* match PSID */
psid_size) == 0) {
"PSID (%s) entry in MDR Table\n", psid);
/* match part numbers */
continue;
} else {
handle->hwfw_match = 0;
no_match = i;
continue;
}
}
}
if (i == MLX_MAX_ID && no_match == 0) {
/* no match found */
handle->hwfw_match = 0;
} else {
if (handle->hwfw_match == 0) {
"image is meant for %s but the hardware "
}
}
}
static void
{
/* get PSID of firmware file */
handle->hwfw_match = 0;
return;
}
/*
* Check the part number of the hardware against the part number
* of the firmware file. If the hardware information is not
* available, check the currently loaded firmware against the
* firmware file to be uploaded.
*/
}
}
static int
{
sizeof (struct mlx_cnx_guid_sect));
"differs from GUID section 0x%x\n"), calculated_crc,
} else {
"with GUID section 0x%x\n", calculated_crc,
}
MLX_OUI) ||
MLX_OUI) ||
MLX_OUI) ||
MLX_OUI)) ||
SUNW_OUI) ||
SUNW_OUI) ||
SUNW_OUI) ||
SUNW_OUI))) {
return (FWFLASH_SUCCESS);
} else {
return (FWFLASH_FAILURE);
}
}