xref: /titanic_51/usr/src/uts/common/io/nxge/npi/npi.h (revision 678453a8ed49104d8adad58f3ba591bdc39883e8)
16f45ec7bSml29623 /*
26f45ec7bSml29623  * CDDL HEADER START
36f45ec7bSml29623  *
46f45ec7bSml29623  * The contents of this file are subject to the terms of the
56f45ec7bSml29623  * Common Development and Distribution License (the "License").
66f45ec7bSml29623  * You may not use this file except in compliance with the License.
76f45ec7bSml29623  *
86f45ec7bSml29623  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
96f45ec7bSml29623  * or http://www.opensolaris.org/os/licensing.
106f45ec7bSml29623  * See the License for the specific language governing permissions
116f45ec7bSml29623  * and limitations under the License.
126f45ec7bSml29623  *
136f45ec7bSml29623  * When distributing Covered Code, include this CDDL HEADER in each
146f45ec7bSml29623  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
156f45ec7bSml29623  * If applicable, add the following below this CDDL HEADER, with the
166f45ec7bSml29623  * fields enclosed by brackets "[]" replaced with your own identifying
176f45ec7bSml29623  * information: Portions Copyright [yyyy] [name of copyright owner]
186f45ec7bSml29623  *
196f45ec7bSml29623  * CDDL HEADER END
206f45ec7bSml29623  */
216f45ec7bSml29623 /*
22*678453a8Sspeer  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
236f45ec7bSml29623  * Use is subject to license terms.
246f45ec7bSml29623  */
256f45ec7bSml29623 
266f45ec7bSml29623 #ifndef _NPI_H
276f45ec7bSml29623 #define	_NPI_H
286f45ec7bSml29623 
296f45ec7bSml29623 #pragma ident	"%Z%%M%	%I%	%E% SMI"
306f45ec7bSml29623 
316f45ec7bSml29623 #ifdef	__cplusplus
326f45ec7bSml29623 extern "C" {
336f45ec7bSml29623 #endif
346f45ec7bSml29623 
356f45ec7bSml29623 #include <nxge_common_impl.h>
366f45ec7bSml29623 
376f45ec7bSml29623 typedef	uint32_t			npi_status_t;
386f45ec7bSml29623 
396f45ec7bSml29623 /* Common Block ID */
406f45ec7bSml29623 
416f45ec7bSml29623 #define	MAC_BLK_ID			0x1
426f45ec7bSml29623 #define	TXMAC_BLK_ID			0x2
436f45ec7bSml29623 #define	RXMAC_BLK_ID			0x3
446f45ec7bSml29623 #define	MIF_BLK_ID			0x4
456f45ec7bSml29623 #define	IPP_BLK_ID			0x5
466f45ec7bSml29623 #define	TXC_BLK_ID			0x6
476f45ec7bSml29623 #define	TXDMA_BLK_ID			0x7
486f45ec7bSml29623 #define	RXDMA_BLK_ID			0x8
496f45ec7bSml29623 #define	ZCP_BLK_ID			0x9
506f45ec7bSml29623 #define	ESPC_BLK_ID			0xa
516f45ec7bSml29623 #define	FFLP_BLK_ID			0xb
526f45ec7bSml29623 #define	PHY_BLK_ID			0xc
536f45ec7bSml29623 #define	ETHER_SERDES_BLK_ID		0xd
546f45ec7bSml29623 #define	PCIE_SERDES_BLK_ID		0xe
556f45ec7bSml29623 #define	VIR_BLK_ID			0xf
56ee5416c9Syc148097 #define	XAUI_BLK_ID			0x10
57ee5416c9Syc148097 #define	XFP_BLK_ID			0x11
586f45ec7bSml29623 
596f45ec7bSml29623 /* Common HW error code */
606f45ec7bSml29623 /* HW unable to exit from reset state. */
616f45ec7bSml29623 #define	RESET_FAILED			0x81
626f45ec7bSml29623 
636f45ec7bSml29623 /* Write operation failed on indirect write. */
646f45ec7bSml29623 #define	WRITE_FAILED			0x82
656f45ec7bSml29623 /* Read operation failed on indirect read.	 */
666f45ec7bSml29623 #define	READ_FAILED			0x83
676f45ec7bSml29623 
686f45ec7bSml29623 /* Error code boundary */
696f45ec7bSml29623 
706f45ec7bSml29623 #define	COMMON_SW_ERR_START		0x40
716f45ec7bSml29623 #define	COMMON_SW_ERR_END		0x4f
726f45ec7bSml29623 #define	BLK_SPEC_SW_ERR_START		0x50
736f45ec7bSml29623 #define	BLK_SPEC_SW_ERR_END		0x7f
746f45ec7bSml29623 #define	COMMON_HW_ERR_START		0x80
756f45ec7bSml29623 #define	COMMON_HW_ERR_END		0x8f
766f45ec7bSml29623 #define	BLK_SPEC_HW_ERR_START		0x90
776f45ec7bSml29623 #define	BLK_SPEC_HW_ERR_END		0xbf
786f45ec7bSml29623 
796f45ec7bSml29623 #define	IS_PORT				0x00100000
806f45ec7bSml29623 #define	IS_CHAN				0x00200000
816f45ec7bSml29623 
826f45ec7bSml29623 /* Common SW errors code */
836f45ec7bSml29623 
846f45ec7bSml29623 #define	PORT_INVALID			0x41	/* Invalid port number */
856f45ec7bSml29623 #define	CHANNEL_INVALID			0x42	/* Invalid dma channel number */
866f45ec7bSml29623 #define	OPCODE_INVALID			0x43	/* Invalid opcode */
876f45ec7bSml29623 #define	REGISTER_INVALID		0x44	/* Invalid register number */
886f45ec7bSml29623 #define	COUNTER_INVALID			0x45	/* Invalid counter number */
896f45ec7bSml29623 #define	CONFIG_INVALID			0x46	/* Invalid config input */
906f45ec7bSml29623 #define	LOGICAL_PAGE_INVALID		0x47	/* Invalid logical page # */
916f45ec7bSml29623 #define	VLAN_INVALID			0x48	/* Invalid Vlan ID */
926f45ec7bSml29623 #define	RDC_TAB_INVALID			0x49	/* Invalid RDC Group Number */
936f45ec7bSml29623 #define	LOCATION_INVALID		0x4a	/* Invalid Entry Location */
946f45ec7bSml29623 
956f45ec7bSml29623 #define	NPI_SUCCESS			0		/* Operation succeed */
966f45ec7bSml29623 #define	NPI_FAILURE			0x80000000	/* Operation failed */
976f45ec7bSml29623 
986f45ec7bSml29623 #define	NPI_CNT_CLR_VAL			0
996f45ec7bSml29623 
1006f45ec7bSml29623 /*
1016f45ec7bSml29623  * Block identifier starts at bit 8.
1026f45ec7bSml29623  */
1036f45ec7bSml29623 #define	NPI_BLOCK_ID_SHIFT		8
1046f45ec7bSml29623 
1056f45ec7bSml29623 /*
1066f45ec7bSml29623  * Port, channel and misc. information starts at bit 12.
1076f45ec7bSml29623  */
1086f45ec7bSml29623 #define	NPI_PORT_CHAN_SHIFT			12
1096f45ec7bSml29623 
1106f45ec7bSml29623 /*
1116f45ec7bSml29623  * Software Block specific error codes start at 0x50.
1126f45ec7bSml29623  */
1136f45ec7bSml29623 #define	NPI_BK_ERROR_START		0x50
1146f45ec7bSml29623 
1156f45ec7bSml29623 /*
1166f45ec7bSml29623  * Hardware block specific error codes start at 0x90.
1176f45ec7bSml29623  */
1186f45ec7bSml29623 #define	NPI_BK_HW_ER_START		0x90
1196f45ec7bSml29623 
1206f45ec7bSml29623 /* Structures for register tracing */
1216f45ec7bSml29623 
1226f45ec7bSml29623 typedef struct _rt_buf {
1236f45ec7bSml29623 	uint32_t	ctl_addr;
124*678453a8Sspeer 	uint32_t	align;
1256f45ec7bSml29623 	uint32_t	val_h32;
126*678453a8Sspeer 	uint32_t	val_l32;
127*678453a8Sspeer 	char		name[16];
1286f45ec7bSml29623 } rt_buf_t;
1296f45ec7bSml29623 
1306f45ec7bSml29623 /*
1316f45ec7bSml29623  * Control Address field format
1326f45ec7bSml29623  *
1336f45ec7bSml29623  * Bit 0 - 23: Address
1346f45ec7bSml29623  * Bit 24 - 25: Function Number
1356f45ec7bSml29623  * Bit 26 - 29: Instance Number
1366f45ec7bSml29623  * Bit 30: Read/Write Direction bit
1376f45ec7bSml29623  * Bit 31: Invalid bit
1386f45ec7bSml29623  */
1396f45ec7bSml29623 
1406f45ec7bSml29623 #define	MAX_RTRACE_ENTRIES	1024
1416f45ec7bSml29623 #define	MAX_RTRACE_IOC_ENTRIES	64
1426f45ec7bSml29623 #define	TRACE_ADDR_MASK		0x00FFFFFF
1436f45ec7bSml29623 #define	TRACE_FUNC_MASK		0x03000000
1446f45ec7bSml29623 #define	TRACE_INST_MASK		0x3C000000
1456f45ec7bSml29623 #define	TRACE_CTL_WR		0x40000000
1466f45ec7bSml29623 #define	TRACE_CTL_INVALID	0x80000000
1476f45ec7bSml29623 #define	TRACE_FUNC_SHIFT	24
1486f45ec7bSml29623 #define	TRACE_INST_SHIFT	26
1496f45ec7bSml29623 #define	MSG_BUF_SIZE		1024
1506f45ec7bSml29623 
1516f45ec7bSml29623 
1526f45ec7bSml29623 typedef struct _rtrace {
1536f45ec7bSml29623 	uint16_t	next_idx;
1546f45ec7bSml29623 	uint16_t	last_idx;
1556f45ec7bSml29623 	boolean_t	wrapped;
156*678453a8Sspeer 	uint64_t	align;
1576f45ec7bSml29623 	rt_buf_t	buf[MAX_RTRACE_ENTRIES];
1586f45ec7bSml29623 } rtrace_t;
1596f45ec7bSml29623 
1606f45ec7bSml29623 typedef struct _err_inject {
1616f45ec7bSml29623 	uint8_t		blk_id;
1626f45ec7bSml29623 	uint8_t		chan;
1636f45ec7bSml29623 	uint32_t	err_id;
1646f45ec7bSml29623 	uint32_t	control;
1656f45ec7bSml29623 } err_inject_t;
1666f45ec7bSml29623 
1676f45ec7bSml29623 /* Configuration options */
1686f45ec7bSml29623 typedef enum config_op {
1696f45ec7bSml29623 	DISABLE = 0,
1706f45ec7bSml29623 	ENABLE,
1716f45ec7bSml29623 	INIT
1726f45ec7bSml29623 } config_op_t;
1736f45ec7bSml29623 
1746f45ec7bSml29623 /* I/O options */
1756f45ec7bSml29623 typedef enum io_op {
1766f45ec7bSml29623 	OP_SET = 0,
1776f45ec7bSml29623 	OP_GET,
1786f45ec7bSml29623 	OP_UPDATE,
1796f45ec7bSml29623 	OP_CLEAR
1806f45ec7bSml29623 } io_op_t;
1816f45ec7bSml29623 
1826f45ec7bSml29623 /* Counter options */
1836f45ec7bSml29623 typedef enum counter_op {
1846f45ec7bSml29623 	SNAP_STICKY = 0,
1856f45ec7bSml29623 	SNAP_ACCUMULATE,
1866f45ec7bSml29623 	CLEAR
1876f45ec7bSml29623 } counter_op_t;
1886f45ec7bSml29623 
1896f45ec7bSml29623 /* NPI attribute */
1906f45ec7bSml29623 typedef struct _npi_attr_t {
1916f45ec7bSml29623 	uint32_t type;
1926f45ec7bSml29623 	uint32_t idata[16];
1936f45ec7bSml29623 	uint32_t odata[16];
1946f45ec7bSml29623 } npi_attr_t;
1956f45ec7bSml29623 
1966f45ec7bSml29623 /* NPI Handle */
1976f45ec7bSml29623 typedef	struct	_npi_handle_function {
1986f45ec7bSml29623 	uint16_t		instance;
1996f45ec7bSml29623 	uint16_t		function;
2006f45ec7bSml29623 } npi_handle_function_t;
2016f45ec7bSml29623 
2026f45ec7bSml29623 /* NPI Handle */
2036f45ec7bSml29623 typedef	struct	_npi_handle {
2046f45ec7bSml29623 	npi_reg_handle_t	regh;
2056f45ec7bSml29623 	npi_reg_ptr_t		regp;
2066f45ec7bSml29623 	boolean_t		is_vraddr; /* virtualization region address */
2076f45ec7bSml29623 	npi_handle_function_t	function;
2086f45ec7bSml29623 	void * nxgep;
2096f45ec7bSml29623 } npi_handle_t;
2106f45ec7bSml29623 
2116f45ec7bSml29623 /* NPI Counter */
2126f45ec7bSml29623 typedef struct _npi_counter_t {
2136f45ec7bSml29623 	uint32_t id;
2146f45ec7bSml29623 	char *name;
2156f45ec7bSml29623 	uint32_t val;
2166f45ec7bSml29623 } npi_counter_t;
2176f45ec7bSml29623 
2186f45ec7bSml29623 /*
2196f45ec7bSml29623  * Commmon definitions for NPI RXDMA and TXDMA functions.
2206f45ec7bSml29623  */
2216f45ec7bSml29623 typedef struct _dma_log_page {
2226f45ec7bSml29623 	uint8_t			page_num;
2236f45ec7bSml29623 	boolean_t		valid;
2246f45ec7bSml29623 	uint8_t			func_num;
2256f45ec7bSml29623 	uint64_t		mask;
2266f45ec7bSml29623 	uint64_t		value;
2276f45ec7bSml29623 	uint64_t		reloc;
2286f45ec7bSml29623 } dma_log_page_t, *p_dma_log_page_t;
2296f45ec7bSml29623 
2306f45ec7bSml29623 extern	rtrace_t npi_rtracebuf;
2316f45ec7bSml29623 void npi_rtrace_buf_init(rtrace_t *);
2326f45ec7bSml29623 void npi_rtrace_update(npi_handle_t, boolean_t, rtrace_t *,
2336f45ec7bSml29623     uint32_t, uint64_t);
234*678453a8Sspeer void npi_trace_update(npi_handle_t, boolean_t, rtrace_t *,
235*678453a8Sspeer     const char *, uint32_t, uint64_t);
2366f45ec7bSml29623 void npi_rtrace_buf_init(rtrace_t *);
2376f45ec7bSml29623 
2386f45ec7bSml29623 void npi_debug_msg(npi_handle_function_t, uint64_t,
2396f45ec7bSml29623 	char *, ...);
2406f45ec7bSml29623 
2416f45ec7bSml29623 #ifdef	NPI_DEBUG
2426f45ec7bSml29623 #define	NPI_DEBUG_MSG(params) npi_debug_msg params
2436f45ec7bSml29623 #else
2446f45ec7bSml29623 #define	NPI_DEBUG_MSG(params)
2456f45ec7bSml29623 #endif
2466f45ec7bSml29623 
2476f45ec7bSml29623 #define	NPI_ERROR_MSG(params) npi_debug_msg params
2486f45ec7bSml29623 #define	NPI_REG_DUMP_MSG(params) npi_debug_msg params
2496f45ec7bSml29623 
2506f45ec7bSml29623 #ifdef	__cplusplus
2516f45ec7bSml29623 }
2526f45ec7bSml29623 #endif
2536f45ec7bSml29623 
2546f45ec7bSml29623 #endif	/* _NPI_H */
255