npi_espc.c revision 2bd43bc76740c0fef669e90cfcaa4e3f3cb2a2f5
/*
* 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
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <npi_espc.h>
#include <nxge_espc.h>
{
return (NPI_SUCCESS);
}
{
return (NPI_SUCCESS);
}
{
if ((addr & ~EPC_EEPROM_ADDR_BITS) != 0) {
" npi_espc_eerprom_entry"
" Invalid input addr <0x%x>\n",
addr));
return (NPI_FAILURE | NPI_ESPC_EEPROM_ADDR_INVALID);
}
switch (op) {
case OP_SET:
*data;
if ((val & EPC_WRITE_COMPLETE) == 0) {
" npi_espc_eeprom_entry"
" HW Error: EEPROM_WR <0x%x>\n",
val));
return (NPI_FAILURE | NPI_ESPC_EEPROM_WRITE_FAILED);
}
break;
case OP_GET:
if ((val & EPC_READ_COMPLETE) == 0) {
" npi_espc_eeprom_entry"
" HW Error: EEPROM_RD <0x%x>",
val));
return (NPI_FAILURE | NPI_ESPC_EEPROM_READ_FAILED);
}
/*
* Workaround for synchronization issues - do a second PIO
*/
if ((val & EPC_READ_COMPLETE) == 0) {
" npi_espc_eeprom_entry HW Error: "
"EEPROM_RD <0x%x>", val));
return (NPI_FAILURE | NPI_ESPC_EEPROM_READ_FAILED);
}
break;
default:
" npi_espc_eeprom_entry"
" Invalid Input addr <0x%x>\n", addr));
return (NPI_FAILURE | NPI_ESPC_OPCODE_INVALID);
}
return (NPI_SUCCESS);
}
{
return (NPI_SUCCESS);
}
{
val &= NUM_PORTS_MASK;
return (NPI_SUCCESS);
}
{
return (NPI_SUCCESS);
}
{
int i, j;
val &= MOD_STR_LEN_MASK;
if (str_len > MAX_MOD_STR_LEN) {
" npi_espc_model_str_get"
" Model string length %d exceeds max %d\n",
return (NPI_FAILURE | NPI_ESPC_STR_LEN_INVALID);
}
/*
* Might have to reverse the order depending on how the string
* is written.
*/
for (i = 0, j = 0; i < str_len; j++) {
}
return (NPI_SUCCESS);
}
{
int i, j;
if (str_len > MAX_BD_MOD_STR_LEN) {
" npi_espc_model_str_get"
" Board Model string length %d "
"exceeds max %d\n",
return (NPI_FAILURE | NPI_ESPC_STR_LEN_INVALID);
}
/*
* Might have to reverse the order depending on how the string
* is written.
*/
for (i = 0, j = 0; i < str_len; j++) {
}
return (NPI_SUCCESS);
}
{
return (NPI_SUCCESS);
}
{
switch (portn) {
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
default:
" npi_espc_port_phy_type_get"
" Invalid Input: portn <%d>",
portn));
return (NPI_FAILURE | NPI_ESPC_PORT_INVALID);
}
return (NPI_SUCCESS);
}
{
val &= MAX_FM_SZ_MASK;
return (NPI_SUCCESS);
}
{
val &= VER_NUM_MASK;
return (NPI_SUCCESS);
}
{
val &= IMG_SZ_MASK;
return (NPI_SUCCESS);
}
{
val &= CHKSUM_MASK;
return (NPI_SUCCESS);
}
{
return (NPI_SUCCESS);
}
void
{
int i;
"Dumping SEEPROM registers directly:\n\n"));
for (i = 0; i < 23; i++) {
"reg[%d] 0x%llx\n",
i, val & 0xffffffff));
}
}
{
return (reg_val);
}
{
data = 0;
return (data);
}
{
int i, len;
/* Fill the vpd_info struct with invalid vals */
for (i = 0; i < ETHERADDRL; i++) {
}
ep = 0;
/* go through the images till OBP image type is found */
/* check for expansion rom header signature */
"npi_espc_vpd_info_get: expansion rom image "
"not found, 0x%x [0x%x 0x%x]", ep,
goto vpd_info_err;
}
/* go to the beginning of the PCI data struct of this image */
/* check for PCI data struct signature "PCIR" */
"npi_espc_vpd_info_get: PCIR sig not found"));
goto vpd_info_err;
}
/* check for image type OBP */
/* go to the next image */
continue;
}
/* find the beginning of the VPD data */
break;
}
/* check first byte of identifier string tag */
"npi_espc_vpd_info_get: Could not find VPD!!"));
goto vpd_info_err;
}
/*
* skip over the ID string descriptor to go to the read-only VPD
* keywords list.
*/
while (i < EXPANSION_ROM_SIZE) {
"nxge_get_vpd_info: Could not find "
"VPD ReadOnly list!! [0x%x] %d",
goto vpd_info_err;
}
/* found a vpd read-only list, get its length */
/* extract keywords */
/*
* Each keyword field is as follows:
* 2 bytes keyword in the form of "Zx" where x = 0,1,2....
* 1 byte keyword data field length - klen
* Now the actual keyword data field:
* 1 byte VPD property instance, 'M' / 'I'
* 2 bytes
* 1 byte VPD property data type, 'B' / 'S'
* 1 byte VPD property value length - n
* Actual property string, length (klen - n - 5) bytes
* Actual property value, length n bytes
*/
int dlen;
char type;
ep += 3;
/*
* Look for the following properties:
*
* local-mac-address:
* -- VPD Instance 'I'
* -- VPD Type String 'B'
* -- property string == local-mac-address
*
* model:
* -- VPD Instance 'M'
* -- VPD Type String 'S'
* -- property string == model
*
* board-model:
* -- VPD Instance 'M'
* -- VPD Type String 'S'
* -- property string == board-model
*
* num-mac-addresses:
* -- VPD Instance 'I'
* -- VPD Type String 'B'
* -- property string == num-mac-addresses
*
* phy-type:
* -- VPD Instance 'I'
* -- VPD Type String 'S'
* -- property string == phy-type
*
* version:
* -- VPD Instance 'M'
* -- VPD Type String 'S'
* -- property string == version
*/
if (type == 'S') {
goto next;
}
"board-model", dlen,
fd_flags |= FD_BD_MODEL;
goto next;
}
goto next;
}
}
goto next;
if (type == 'B') {
"local-mac-address", dlen,
fd_flags |= FD_MAC_ADDR;
goto next;
}
"num-mac-addresses", dlen,
fd_flags |= FD_NUM_MACS;
}
} else if (type == 'S') {
"phy-type", dlen,
fd_flags |= FD_PHY_TYPE;
}
}
goto next;
} else {
goto vpd_info_err;
}
next:
goto vpd_success;
}
i += len + 3;
}
return (NPI_SUCCESS);
return (NPI_FAILURE);
}
static int
char *val)
{
int i;
for (i = 0; i < prop_len; i++) {
return (0);
}
for (i = 0; i < len; i++)
return (1);
}