1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _NPI_ESPC_H 27 #define _NPI_ESPC_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #include <npi.h> 34 #include <nxge_espc_hw.h> 35 36 #define EPC_WAIT_RW_COMP(handle, val_p, comp_bit) {\ 37 uint32_t cnt = MAX_PIO_RETRIES;\ 38 do {\ 39 NXGE_DELAY(EPC_RW_WAIT);\ 40 NXGE_REG_RD64(handle, ESPC_REG_ADDR(ESPC_PIO_STATUS_REG),\ 41 val_p); cnt--;\ 42 } while (((val & comp_bit) == 0) && (cnt > 0));\ 43 } 44 45 /* ESPC specific errors */ 46 47 #define ESPC_EEPROM_ADDR_INVALID 0x51 48 #define ESPC_STR_LEN_INVALID 0x91 49 50 /* ESPC error return macros */ 51 52 #define NPI_ESPC_EEPROM_ADDR_INVALID ((ESPC_BLK_ID << 8) |\ 53 ESPC_EEPROM_ADDR_INVALID) 54 #define NPI_ESPC_EEPROM_WRITE_FAILED ((ESPC_BLK_ID << 8) | WRITE_FAILED) 55 #define NPI_ESPC_EEPROM_READ_FAILED ((ESPC_BLK_ID << 8) | READ_FAILED) 56 #define NPI_ESPC_OPCODE_INVALID ((ESPC_BLK_ID << 8) | OPCODE_INVALID) 57 #define NPI_ESPC_STR_LEN_INVALID ((ESPC_BLK_ID << 8) |\ 58 ESPC_STR_LEN_INVALID) 59 #define NPI_ESPC_PORT_INVALID ((ESPC_BLK_ID << 8) | PORT_INVALID) 60 61 /* EEPROM size, Fcode and VPD definitions */ 62 63 /* 64 * VPD information. 65 */ 66 #define NXGE_VPD_MOD_LEN 32 67 #define NXGE_VPD_BD_MOD_LEN 16 68 #define NXGE_VPD_PHY_LEN 5 69 #define NXGE_VPD_VER_LEN 60 70 typedef struct _npi_vpd_info_t { 71 uint8_t mac_addr[ETHERADDRL]; 72 uint8_t num_macs; 73 char model[NXGE_VPD_MOD_LEN]; 74 char bd_model[NXGE_VPD_BD_MOD_LEN]; 75 char phy_type[NXGE_VPD_PHY_LEN]; 76 char ver[NXGE_VPD_VER_LEN]; 77 boolean_t ver_valid; 78 boolean_t present; 79 } npi_vpd_info_t, *p_npi_vpd_info_t; 80 81 #define NXGE_FCODE_ID_STR "FCode " 82 #define NXGE_FCODE_VER_STR_LEN 5 83 #define NXGE_VPD_VALID_VER_W 3 84 #define NXGE_VPD_VALID_VER_F 4 85 #define EXPANSION_ROM_SIZE 65536 86 #define FD_MODEL 0x01 87 #define FD_BD_MODEL 0x02 88 #define FD_MAC_ADDR 0x04 89 #define FD_NUM_MACS 0x08 90 #define FD_PHY_TYPE 0x10 91 #define FD_FW_VERSION 0x20 92 #define FD_ALL 0x3f 93 94 npi_status_t npi_espc_pio_enable(npi_handle_t); 95 npi_status_t npi_espc_pio_disable(npi_handle_t); 96 npi_status_t npi_espc_eeprom_entry(npi_handle_t, io_op_t, 97 uint32_t, uint8_t *); 98 npi_status_t npi_espc_mac_addr_get(npi_handle_t, uint8_t *); 99 npi_status_t npi_espc_num_ports_get(npi_handle_t, uint8_t *); 100 npi_status_t npi_espc_num_macs_get(npi_handle_t, uint8_t *); 101 npi_status_t npi_espc_model_str_get(npi_handle_t, char *); 102 npi_status_t npi_espc_bd_model_str_get(npi_handle_t, char *); 103 npi_status_t npi_espc_phy_type_get(npi_handle_t, uint8_t *); 104 npi_status_t npi_espc_port_phy_type_get(npi_handle_t, uint8_t *, 105 uint8_t); 106 npi_status_t npi_espc_max_frame_get(npi_handle_t, uint16_t *); 107 npi_status_t npi_espc_version_get(npi_handle_t, uint16_t *); 108 npi_status_t npi_espc_img_sz_get(npi_handle_t, uint16_t *); 109 npi_status_t npi_espc_chksum_get(npi_handle_t, uint8_t *); 110 npi_status_t npi_espc_intr_num_get(npi_handle_t, uint8_t *); 111 uint32_t npi_espc_reg_get(npi_handle_t, int); 112 void npi_espc_dump(npi_handle_t); 113 npi_status_t npi_espc_vpd_info_get(npi_handle_t, p_npi_vpd_info_t, uint32_t); 114 115 #ifdef __cplusplus 116 } 117 #endif 118 119 #endif /* _NPI_ESPC_H */ 120