13859Sml29623 /* 23859Sml29623 * CDDL HEADER START 33859Sml29623 * 43859Sml29623 * The contents of this file are subject to the terms of the 53859Sml29623 * Common Development and Distribution License (the "License"). 63859Sml29623 * You may not use this file except in compliance with the License. 73859Sml29623 * 83859Sml29623 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 93859Sml29623 * or http://www.opensolaris.org/os/licensing. 103859Sml29623 * See the License for the specific language governing permissions 113859Sml29623 * and limitations under the License. 123859Sml29623 * 133859Sml29623 * When distributing Covered Code, include this CDDL HEADER in each 143859Sml29623 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 153859Sml29623 * If applicable, add the following below this CDDL HEADER, with the 163859Sml29623 * fields enclosed by brackets "[]" replaced with your own identifying 173859Sml29623 * information: Portions Copyright [yyyy] [name of copyright owner] 183859Sml29623 * 193859Sml29623 * CDDL HEADER END 203859Sml29623 */ 213859Sml29623 /* 22*6495Sspeer * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 233859Sml29623 * Use is subject to license terms. 243859Sml29623 */ 253859Sml29623 263859Sml29623 #ifndef _NPI_H 273859Sml29623 #define _NPI_H 283859Sml29623 293859Sml29623 #pragma ident "%Z%%M% %I% %E% SMI" 303859Sml29623 313859Sml29623 #ifdef __cplusplus 323859Sml29623 extern "C" { 333859Sml29623 #endif 343859Sml29623 353859Sml29623 #include <nxge_common_impl.h> 363859Sml29623 373859Sml29623 typedef uint32_t npi_status_t; 383859Sml29623 393859Sml29623 /* Common Block ID */ 403859Sml29623 413859Sml29623 #define MAC_BLK_ID 0x1 423859Sml29623 #define TXMAC_BLK_ID 0x2 433859Sml29623 #define RXMAC_BLK_ID 0x3 443859Sml29623 #define MIF_BLK_ID 0x4 453859Sml29623 #define IPP_BLK_ID 0x5 463859Sml29623 #define TXC_BLK_ID 0x6 473859Sml29623 #define TXDMA_BLK_ID 0x7 483859Sml29623 #define RXDMA_BLK_ID 0x8 493859Sml29623 #define ZCP_BLK_ID 0x9 503859Sml29623 #define ESPC_BLK_ID 0xa 513859Sml29623 #define FFLP_BLK_ID 0xb 523859Sml29623 #define PHY_BLK_ID 0xc 533859Sml29623 #define ETHER_SERDES_BLK_ID 0xd 543859Sml29623 #define PCIE_SERDES_BLK_ID 0xe 553859Sml29623 #define VIR_BLK_ID 0xf 565060Syc148097 #define XAUI_BLK_ID 0x10 575060Syc148097 #define XFP_BLK_ID 0x11 583859Sml29623 593859Sml29623 /* Common HW error code */ 603859Sml29623 /* HW unable to exit from reset state. */ 613859Sml29623 #define RESET_FAILED 0x81 623859Sml29623 633859Sml29623 /* Write operation failed on indirect write. */ 643859Sml29623 #define WRITE_FAILED 0x82 653859Sml29623 /* Read operation failed on indirect read. */ 663859Sml29623 #define READ_FAILED 0x83 673859Sml29623 683859Sml29623 /* Error code boundary */ 693859Sml29623 703859Sml29623 #define COMMON_SW_ERR_START 0x40 713859Sml29623 #define COMMON_SW_ERR_END 0x4f 723859Sml29623 #define BLK_SPEC_SW_ERR_START 0x50 733859Sml29623 #define BLK_SPEC_SW_ERR_END 0x7f 743859Sml29623 #define COMMON_HW_ERR_START 0x80 753859Sml29623 #define COMMON_HW_ERR_END 0x8f 763859Sml29623 #define BLK_SPEC_HW_ERR_START 0x90 773859Sml29623 #define BLK_SPEC_HW_ERR_END 0xbf 783859Sml29623 793859Sml29623 #define IS_PORT 0x00100000 803859Sml29623 #define IS_CHAN 0x00200000 813859Sml29623 823859Sml29623 /* Common SW errors code */ 833859Sml29623 843859Sml29623 #define PORT_INVALID 0x41 /* Invalid port number */ 853859Sml29623 #define CHANNEL_INVALID 0x42 /* Invalid dma channel number */ 863859Sml29623 #define OPCODE_INVALID 0x43 /* Invalid opcode */ 873859Sml29623 #define REGISTER_INVALID 0x44 /* Invalid register number */ 883859Sml29623 #define COUNTER_INVALID 0x45 /* Invalid counter number */ 893859Sml29623 #define CONFIG_INVALID 0x46 /* Invalid config input */ 903859Sml29623 #define LOGICAL_PAGE_INVALID 0x47 /* Invalid logical page # */ 913859Sml29623 #define VLAN_INVALID 0x48 /* Invalid Vlan ID */ 923859Sml29623 #define RDC_TAB_INVALID 0x49 /* Invalid RDC Group Number */ 933859Sml29623 #define LOCATION_INVALID 0x4a /* Invalid Entry Location */ 943859Sml29623 953859Sml29623 #define NPI_SUCCESS 0 /* Operation succeed */ 963859Sml29623 #define NPI_FAILURE 0x80000000 /* Operation failed */ 973859Sml29623 983859Sml29623 #define NPI_CNT_CLR_VAL 0 993859Sml29623 1003859Sml29623 /* 1013859Sml29623 * Block identifier starts at bit 8. 1023859Sml29623 */ 1033859Sml29623 #define NPI_BLOCK_ID_SHIFT 8 1043859Sml29623 1053859Sml29623 /* 1063859Sml29623 * Port, channel and misc. information starts at bit 12. 1073859Sml29623 */ 1083859Sml29623 #define NPI_PORT_CHAN_SHIFT 12 1093859Sml29623 1103859Sml29623 /* 1113859Sml29623 * Software Block specific error codes start at 0x50. 1123859Sml29623 */ 1133859Sml29623 #define NPI_BK_ERROR_START 0x50 1143859Sml29623 1153859Sml29623 /* 1163859Sml29623 * Hardware block specific error codes start at 0x90. 1173859Sml29623 */ 1183859Sml29623 #define NPI_BK_HW_ER_START 0x90 1193859Sml29623 1203859Sml29623 /* Structures for register tracing */ 1213859Sml29623 1223859Sml29623 typedef struct _rt_buf { 1233859Sml29623 uint32_t ctl_addr; 124*6495Sspeer uint32_t align; 125*6495Sspeer uint32_t val_h32; 1263859Sml29623 uint32_t val_l32; 127*6495Sspeer char name[16]; 1283859Sml29623 } rt_buf_t; 1293859Sml29623 1303859Sml29623 /* 1313859Sml29623 * Control Address field format 1323859Sml29623 * 1333859Sml29623 * Bit 0 - 23: Address 1343859Sml29623 * Bit 24 - 25: Function Number 1353859Sml29623 * Bit 26 - 29: Instance Number 1363859Sml29623 * Bit 30: Read/Write Direction bit 1373859Sml29623 * Bit 31: Invalid bit 1383859Sml29623 */ 1393859Sml29623 1403859Sml29623 #define MAX_RTRACE_ENTRIES 1024 1413859Sml29623 #define MAX_RTRACE_IOC_ENTRIES 64 1423859Sml29623 #define TRACE_ADDR_MASK 0x00FFFFFF 1433859Sml29623 #define TRACE_FUNC_MASK 0x03000000 1443859Sml29623 #define TRACE_INST_MASK 0x3C000000 1453859Sml29623 #define TRACE_CTL_WR 0x40000000 1463859Sml29623 #define TRACE_CTL_INVALID 0x80000000 1473859Sml29623 #define TRACE_FUNC_SHIFT 24 1483859Sml29623 #define TRACE_INST_SHIFT 26 1493859Sml29623 #define MSG_BUF_SIZE 1024 1503859Sml29623 1513859Sml29623 1523859Sml29623 typedef struct _rtrace { 1533859Sml29623 uint16_t next_idx; 1543859Sml29623 uint16_t last_idx; 1553859Sml29623 boolean_t wrapped; 156*6495Sspeer uint64_t align; 1573859Sml29623 rt_buf_t buf[MAX_RTRACE_ENTRIES]; 1583859Sml29623 } rtrace_t; 1593859Sml29623 1603859Sml29623 typedef struct _err_inject { 1613859Sml29623 uint8_t blk_id; 1623859Sml29623 uint8_t chan; 1633859Sml29623 uint32_t err_id; 1643859Sml29623 uint32_t control; 1653859Sml29623 } err_inject_t; 1663859Sml29623 1673859Sml29623 /* Configuration options */ 1683859Sml29623 typedef enum config_op { 1693859Sml29623 DISABLE = 0, 1703859Sml29623 ENABLE, 1713859Sml29623 INIT 1723859Sml29623 } config_op_t; 1733859Sml29623 1743859Sml29623 /* I/O options */ 1753859Sml29623 typedef enum io_op { 1763859Sml29623 OP_SET = 0, 1773859Sml29623 OP_GET, 1783859Sml29623 OP_UPDATE, 1793859Sml29623 OP_CLEAR 1803859Sml29623 } io_op_t; 1813859Sml29623 1823859Sml29623 /* Counter options */ 1833859Sml29623 typedef enum counter_op { 1843859Sml29623 SNAP_STICKY = 0, 1853859Sml29623 SNAP_ACCUMULATE, 1863859Sml29623 CLEAR 1873859Sml29623 } counter_op_t; 1883859Sml29623 1893859Sml29623 /* NPI attribute */ 1903859Sml29623 typedef struct _npi_attr_t { 1913859Sml29623 uint32_t type; 1923859Sml29623 uint32_t idata[16]; 1933859Sml29623 uint32_t odata[16]; 1943859Sml29623 } npi_attr_t; 1953859Sml29623 1963859Sml29623 /* NPI Handle */ 1973859Sml29623 typedef struct _npi_handle_function { 1983859Sml29623 uint16_t instance; 1993859Sml29623 uint16_t function; 2003859Sml29623 } npi_handle_function_t; 2013859Sml29623 2023859Sml29623 /* NPI Handle */ 2033859Sml29623 typedef struct _npi_handle { 2043859Sml29623 npi_reg_handle_t regh; 2053859Sml29623 npi_reg_ptr_t regp; 2063859Sml29623 boolean_t is_vraddr; /* virtualization region address */ 2073859Sml29623 npi_handle_function_t function; 2083859Sml29623 void * nxgep; 2093859Sml29623 } npi_handle_t; 2103859Sml29623 2113859Sml29623 /* NPI Counter */ 2123859Sml29623 typedef struct _npi_counter_t { 2133859Sml29623 uint32_t id; 2143859Sml29623 char *name; 2153859Sml29623 uint32_t val; 2163859Sml29623 } npi_counter_t; 2173859Sml29623 2183859Sml29623 /* 2193859Sml29623 * Commmon definitions for NPI RXDMA and TXDMA functions. 2203859Sml29623 */ 2213859Sml29623 typedef struct _dma_log_page { 2223859Sml29623 uint8_t page_num; 2233859Sml29623 boolean_t valid; 2243859Sml29623 uint8_t func_num; 2253859Sml29623 uint64_t mask; 2263859Sml29623 uint64_t value; 2273859Sml29623 uint64_t reloc; 2283859Sml29623 } dma_log_page_t, *p_dma_log_page_t; 2293859Sml29623 2303859Sml29623 extern rtrace_t npi_rtracebuf; 2313859Sml29623 void npi_rtrace_buf_init(rtrace_t *); 2323859Sml29623 void npi_rtrace_update(npi_handle_t, boolean_t, rtrace_t *, 233*6495Sspeer uint32_t, uint64_t); 234*6495Sspeer void npi_trace_update(npi_handle_t, boolean_t, rtrace_t *, 235*6495Sspeer const char *, uint32_t, uint64_t); 2363859Sml29623 void npi_rtrace_buf_init(rtrace_t *); 2373859Sml29623 2383859Sml29623 void npi_debug_msg(npi_handle_function_t, uint64_t, 2393859Sml29623 char *, ...); 2403859Sml29623 2413859Sml29623 #ifdef NPI_DEBUG 2423859Sml29623 #define NPI_DEBUG_MSG(params) npi_debug_msg params 2433859Sml29623 #else 2443859Sml29623 #define NPI_DEBUG_MSG(params) 2453859Sml29623 #endif 2463859Sml29623 2473859Sml29623 #define NPI_ERROR_MSG(params) npi_debug_msg params 2483859Sml29623 #define NPI_REG_DUMP_MSG(params) npi_debug_msg params 2493859Sml29623 2503859Sml29623 #ifdef __cplusplus 2513859Sml29623 } 2523859Sml29623 #endif 2533859Sml29623 2543859Sml29623 #endif /* _NPI_H */ 255