xref: /illumos-gate/usr/src/uts/common/io/hxge/hpi.h (revision 2d6eb4a5)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _HPI_H
27 #define	_HPI_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/types.h>
34 #include <hxge_common_impl.h>
35 #include <hxge_common.h>
36 
37 typedef	uint32_t hpi_status_t;
38 
39 /* Common Block ID */
40 #define	VMAC_BLK_ID			0x1
41 #define	TXDMA_BLK_ID			0x2
42 #define	RXDMA_BLK_ID			0x3
43 #define	PFC_BLK_ID			0x4
44 #define	VIR_BLK_ID			0x5
45 #define	PEU_BLK_ID			0x6
46 
47 /* Common HW error code */
48 /* HW unable to exit from reset state. */
49 #define	RESET_FAILED			0x81
50 
51 /* Write operation failed on indirect write. */
52 #define	WRITE_FAILED			0x82
53 /* Read operation failed on indirect read.	 */
54 #define	READ_FAILED			0x83
55 
56 /* Common SW errors code */
57 
58 #define	PORT_INVALID			0x41	/* Invalid port number */
59 #define	CHANNEL_INVALID			0x42	/* Invalid dma channel number */
60 #define	OPCODE_INVALID			0x43	/* Invalid opcode */
61 #define	REGISTER_INVALID		0x44	/* Invalid register number */
62 #define	COUNTER_INVALID			0x45	/* Invalid counter number */
63 #define	CONFIG_INVALID			0x46	/* Invalid config input */
64 #define	LOGICAL_PAGE_INVALID		0x47	/* Invalid logical page # */
65 #define	VLAN_INVALID			0x48	/* Invalid Vlan ID */
66 #define	RDC_TAB_INVALID			0x49	/* Invalid RDC Group Number */
67 #define	LOCATION_INVALID		0x4a	/* Invalid Entry Location */
68 
69 #define	HPI_SUCCESS			0		/* Operation succeed */
70 #define	HPI_FAILURE			0x80000000	/* Operation failed */
71 
72 /*
73  * Block identifier starts at bit 8.
74  */
75 #define	HPI_BLOCK_ID_SHIFT		8
76 
77 /*
78  * Port, channel and misc. information starts at bit 12.
79  */
80 #define	HPI_PORT_CHAN_SHIFT		12
81 
82 /*
83  * Software Block specific error codes start at 0x50.
84  */
85 #define	HPI_BK_ERROR_START		0x50
86 
87 /*
88  * Hardware block specific error codes start at 0x90.
89  */
90 #define	HPI_BK_HW_ER_START		0x90
91 
92 /* Structures for register tracing */
93 
94 typedef struct _rt_buf {
95 	uint32_t	ctl_addr;
96 	uint32_t	val_l32;
97 	uint32_t	val_h32;
98 } rt_buf_t;
99 
100 /*
101  * Control Address field format
102  *
103  * Bit 0 - 23: Address
104  * Bit 24 - 25: Function Number
105  * Bit 26 - 29: Instance Number
106  * Bit 30: Read/Write Direction bit
107  * Bit 31: Invalid bit
108  */
109 
110 #define	MAX_RTRACE_ENTRIES	1024
111 #define	MAX_RTRACE_IOC_ENTRIES	64
112 #define	TRACE_ADDR_MASK		0x00FFFFFF
113 #define	TRACE_FUNC_MASK		0x03000000
114 #define	TRACE_INST_MASK		0x3C000000
115 #define	TRACE_CTL_WR		0x40000000
116 #define	TRACE_CTL_INVALID	0x80000000
117 #define	TRACE_FUNC_SHIFT	24
118 #define	TRACE_INST_SHIFT	26
119 #define	MSG_BUF_SIZE		1024
120 
121 
122 typedef struct _rtrace {
123 	uint16_t	next_idx;
124 	uint16_t	last_idx;
125 	boolean_t	wrapped;
126 	rt_buf_t	buf[MAX_RTRACE_ENTRIES];
127 } rtrace_t;
128 
129 /* Configuration options */
130 typedef enum config_op {
131 	DISABLE = 0,
132 	ENABLE,
133 	INIT
134 } config_op_t;
135 
136 /* I/O options */
137 typedef enum io_op {
138 	OP_SET = 0,
139 	OP_GET,
140 	OP_UPDATE,
141 	OP_CLEAR
142 } io_op_t;
143 
144 /* HPI Handle */
145 typedef	struct	_hpi_handle_function {
146 	uint16_t		instance;
147 	uint16_t		function;
148 } hpi_handle_function_t;
149 
150 /* HPI Handle */
151 typedef	struct	_hpi_handle {
152 	hpi_reg_handle_t	regh;
153 	hpi_reg_ptr_t		regp;
154 	boolean_t		is_vraddr; /* virtualization region address */
155 	hpi_handle_function_t	function;
156 	void			*hxgep;
157 } hpi_handle_t;
158 
159 extern	rtrace_t hpi_rtracebuf;
160 void hpi_rtrace_update(hpi_handle_t handle, boolean_t wr, rtrace_t *rt,
161     uint32_t addr, uint64_t val);
162 void hpi_rtrace_buf_init(rtrace_t *rt);
163 
164 void hpi_debug_msg(hpi_handle_function_t function, uint64_t level,
165     char *fmt, ...);
166 
167 #ifdef	HPI_DEBUG
168 #define	HPI_DEBUG_MSG(params) hpi_debug_msg params
169 #else
170 #define	HPI_DEBUG_MSG(params)
171 #endif
172 
173 #define	HPI_ERROR_MSG(params) hpi_debug_msg params
174 
175 #ifdef	__cplusplus
176 }
177 #endif
178 
179 #endif	/* _HPI_H */
180