xref: /illumos-gate/usr/src/uts/common/io/cxgbe/t4nex/cudbg_lib.h (revision 698f4ab6008be205f4362675967638572eef4f21)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source. A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*-
13  * Copyright (c) 2017 Chelsio Communications, Inc.
14  * All rights reserved.
15  *
16  * Redistribution and use in source and binary forms, with or without
17  * modification, are permitted provided that the following conditions
18  * are met:
19  * 1. Redistributions of source code must retain the above copyright
20  *    notice, this list of conditions and the following disclaimer.
21  * 2. Redistributions in binary form must reproduce the above copyright
22  *    notice, this list of conditions and the following disclaimer in the
23  *    documentation and/or other materials provided with the distribution.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  */
37 
38 #ifndef __CUDBG_LIB_H__
39 #define __CUDBG_LIB_H__
40 
41 #ifndef min_t
42 #define min_t(type, _a, _b)   (((type)(_a) < (type)(_b)) ? (type)(_a) : (type)(_b))
43 #endif
44 
45 static int collect_reg_dump(struct cudbg_init *, struct cudbg_buffer *,
46 			    struct cudbg_error *);
47 static int collect_fw_devlog(struct cudbg_init *, struct cudbg_buffer *,
48 			     struct cudbg_error *);
49 static int collect_cim_qcfg(struct cudbg_init *, struct cudbg_buffer *,
50 			    struct cudbg_error *);
51 static int collect_cim_la(struct cudbg_init *, struct cudbg_buffer *,
52 			  struct cudbg_error *);
53 static int collect_cim_ma_la(struct cudbg_init *, struct cudbg_buffer *,
54 			     struct cudbg_error *);
55 static int collect_cim_obq_ulp0(struct cudbg_init *, struct cudbg_buffer *,
56 				struct cudbg_error *);
57 static int collect_cim_obq_ulp1(struct cudbg_init *, struct cudbg_buffer *,
58 				struct cudbg_error *);
59 static int collect_cim_obq_ulp2(struct cudbg_init *, struct cudbg_buffer *,
60 				struct cudbg_error *);
61 static int collect_cim_obq_ulp3(struct cudbg_init *, struct cudbg_buffer *,
62 				struct cudbg_error *);
63 static int collect_cim_obq_sge(struct cudbg_init *, struct cudbg_buffer *,
64 			       struct cudbg_error *);
65 static int collect_cim_obq_ncsi(struct cudbg_init *, struct cudbg_buffer *,
66 				struct cudbg_error *);
67 static int collect_cim_ibq_tp0(struct cudbg_init *, struct cudbg_buffer *,
68 			       struct cudbg_error *);
69 static int collect_cim_ibq_tp1(struct cudbg_init *, struct cudbg_buffer *,
70 			       struct cudbg_error *);
71 static int collect_cim_ibq_ulp(struct cudbg_init *, struct cudbg_buffer *,
72 			       struct cudbg_error *);
73 static int collect_cim_ibq_sge0(struct cudbg_init *, struct cudbg_buffer *,
74 				struct cudbg_error *);
75 static int collect_cim_ibq_sge1(struct cudbg_init *, struct cudbg_buffer *,
76 				struct cudbg_error *);
77 static int collect_cim_ibq_ncsi(struct cudbg_init *, struct cudbg_buffer *,
78 				struct cudbg_error *);
79 static int collect_edc0_meminfo(struct cudbg_init *, struct cudbg_buffer *,
80 				struct cudbg_error *);
81 static int collect_edc1_meminfo(struct cudbg_init *, struct cudbg_buffer *,
82 				struct cudbg_error *);
83 static int collect_mc0_meminfo(struct cudbg_init *, struct cudbg_buffer *,
84 			       struct cudbg_error *);
85 static int collect_mc1_meminfo(struct cudbg_init *, struct cudbg_buffer *,
86 			       struct cudbg_error *);
87 static int collect_rss(struct cudbg_init *, struct cudbg_buffer *,
88 		       struct cudbg_error *);
89 static int collect_rss_key(struct cudbg_init *, struct cudbg_buffer *,
90 			   struct cudbg_error *);
91 static int collect_rss_pf_config(struct cudbg_init *, struct cudbg_buffer *,
92 				 struct cudbg_error *);
93 static int collect_rss_vf_config(struct cudbg_init *, struct cudbg_buffer *,
94 				 struct cudbg_error *);
95 static int collect_rss_config(struct cudbg_init *, struct cudbg_buffer *,
96 			      struct cudbg_error *);
97 static int collect_path_mtu(struct cudbg_init *, struct cudbg_buffer *,
98 			    struct cudbg_error *);
99 static int collect_sw_state(struct cudbg_init *, struct cudbg_buffer *,
100 			    struct cudbg_error *);
101 int collect_wtp_data(struct cudbg_init *, struct cudbg_buffer *,
102 		     struct cudbg_error *);
103 static int collect_pm_stats(struct cudbg_init *, struct cudbg_buffer *,
104 			    struct cudbg_error *);
105 static int collect_hw_sched(struct cudbg_init *, struct cudbg_buffer *,
106 			    struct cudbg_error *);
107 static int collect_tcp_stats(struct cudbg_init *, struct cudbg_buffer *,
108 			     struct cudbg_error *);
109 static int collect_tp_err_stats(struct cudbg_init *, struct cudbg_buffer *,
110 				struct cudbg_error *);
111 static int collect_fcoe_stats(struct cudbg_init *, struct cudbg_buffer *,
112 			      struct cudbg_error *);
113 static int collect_rdma_stats(struct cudbg_init *, struct cudbg_buffer *,
114 			      struct cudbg_error *);
115 static int collect_tp_indirect(struct cudbg_init *, struct cudbg_buffer *,
116 			       struct cudbg_error *);
117 static int collect_sge_indirect(struct cudbg_init *, struct cudbg_buffer *,
118 				struct cudbg_error *);
119 static int collect_cpl_stats(struct cudbg_init *, struct cudbg_buffer *,
120 			     struct cudbg_error *);
121 static int collect_ddp_stats(struct cudbg_init *, struct cudbg_buffer *,
122 			     struct cudbg_error *);
123 static int collect_wc_stats(struct cudbg_init *, struct cudbg_buffer *,
124 			    struct cudbg_error *);
125 static int collect_ulprx_la(struct cudbg_init *, struct cudbg_buffer *,
126 			    struct cudbg_error *);
127 static int collect_lb_stats(struct cudbg_init *, struct cudbg_buffer *,
128 			    struct cudbg_error *);
129 static int collect_tp_la(struct cudbg_init *, struct cudbg_buffer *,
130 			 struct cudbg_error *);
131 static int collect_meminfo(struct cudbg_init *, struct cudbg_buffer *,
132 			   struct cudbg_error *);
133 static int collect_cim_pif_la(struct cudbg_init *, struct cudbg_buffer *,
134 			      struct cudbg_error *);
135 static int collect_clk_info(struct cudbg_init *, struct cudbg_buffer *,
136 			    struct cudbg_error *);
137 static int collect_obq_sge_rx_q0(struct cudbg_init *, struct cudbg_buffer *,
138 				 struct cudbg_error *);
139 static int collect_obq_sge_rx_q1(struct cudbg_init *, struct cudbg_buffer *,
140 				 struct cudbg_error *);
141 static int collect_macstats(struct cudbg_init *, struct cudbg_buffer *,
142 			    struct cudbg_error *);
143 static int collect_pcie_indirect(struct cudbg_init *, struct cudbg_buffer *,
144 				 struct cudbg_error *);
145 static int collect_pm_indirect(struct cudbg_init *, struct cudbg_buffer *,
146 			       struct cudbg_error *);
147 static int collect_full(struct cudbg_init *, struct cudbg_buffer *,
148 			struct cudbg_error *);
149 static int collect_tx_rate(struct cudbg_init *, struct cudbg_buffer *,
150 			   struct cudbg_error *);
151 static int collect_tid(struct cudbg_init *, struct cudbg_buffer *,
152 		       struct cudbg_error *);
153 static int collect_pcie_config(struct cudbg_init *, struct cudbg_buffer *,
154 			       struct cudbg_error *);
155 static int collect_dump_context(struct cudbg_init *, struct cudbg_buffer *,
156 				struct cudbg_error *);
157 static int collect_mps_tcam(struct cudbg_init *, struct cudbg_buffer *,
158 			    struct cudbg_error *);
159 static int collect_vpd_data(struct cudbg_init *, struct cudbg_buffer *,
160 			    struct cudbg_error *);
161 static int collect_le_tcam(struct cudbg_init *, struct cudbg_buffer *,
162 			   struct cudbg_error *);
163 static int collect_cctrl(struct cudbg_init *, struct cudbg_buffer *,
164 			 struct cudbg_error *);
165 static int collect_ma_indirect(struct cudbg_init *, struct cudbg_buffer *,
166 			       struct cudbg_error *);
167 static int collect_ulptx_la(struct cudbg_init *, struct cudbg_buffer *,
168 		struct cudbg_error *);
169 static int collect_up_cim_indirect(struct cudbg_init *, struct cudbg_buffer *,
170 				   struct cudbg_error *);
171 static int collect_pbt_tables(struct cudbg_init *, struct cudbg_buffer *,
172 			      struct cudbg_error *);
173 static int collect_mbox_log(struct cudbg_init *, struct cudbg_buffer *,
174 			    struct cudbg_error *);
175 static int collect_hma_indirect(struct cudbg_init *, struct cudbg_buffer *,
176 				struct cudbg_error *);
177 
178 static int (*process_entity[])
179 	(struct cudbg_init *, struct cudbg_buffer *, struct cudbg_error *) = {
180 		collect_reg_dump,
181 		collect_fw_devlog,
182 		collect_cim_la,		/*3*/
183 		collect_cim_ma_la,
184 		collect_cim_qcfg,
185 		collect_cim_ibq_tp0,
186 		collect_cim_ibq_tp1,
187 		collect_cim_ibq_ulp,
188 		collect_cim_ibq_sge0,
189 		collect_cim_ibq_sge1,
190 		collect_cim_ibq_ncsi,
191 		collect_cim_obq_ulp0,
192 		collect_cim_obq_ulp1,	/*13*/
193 		collect_cim_obq_ulp2,
194 		collect_cim_obq_ulp3,
195 		collect_cim_obq_sge,
196 		collect_cim_obq_ncsi,
197 		collect_edc0_meminfo,
198 		collect_edc1_meminfo,
199 		collect_mc0_meminfo,
200 		collect_mc1_meminfo,
201 		collect_rss,		/*22*/
202 		collect_rss_pf_config,
203 		collect_rss_key,
204 		collect_rss_vf_config,
205 		collect_rss_config,	/*26*/
206 		collect_path_mtu,	/*27*/
207 		collect_sw_state,
208 		collect_wtp_data,
209 		collect_pm_stats,
210 		collect_hw_sched,
211 		collect_tcp_stats,
212 		collect_tp_err_stats,
213 		collect_fcoe_stats,
214 		collect_rdma_stats,
215 		collect_tp_indirect,
216 		collect_sge_indirect,
217 		collect_cpl_stats,
218 		collect_ddp_stats,
219 		collect_wc_stats,
220 		collect_ulprx_la,
221 		collect_lb_stats,
222 		collect_tp_la,
223 		collect_meminfo,
224 		collect_cim_pif_la,
225 		collect_clk_info,
226 		collect_obq_sge_rx_q0,
227 		collect_obq_sge_rx_q1,
228 		collect_macstats,
229 		collect_pcie_indirect,
230 		collect_pm_indirect,
231 		collect_full,
232 		collect_tx_rate,
233 		collect_tid,
234 		collect_pcie_config,
235 		collect_dump_context,
236 		collect_mps_tcam,
237 		collect_vpd_data,
238 		collect_le_tcam,
239 		collect_cctrl,
240 		collect_ma_indirect,
241 		collect_ulptx_la,
242 		NULL,			/* ext entity */
243 		collect_up_cim_indirect,
244 		collect_pbt_tables,
245 		collect_mbox_log,
246 		collect_hma_indirect,
247 	};
248 
249 struct large_entity {
250 	int entity_code;
251 	int skip_flag;
252 	int priority; /* 1 is high priority */
253 };
254 
255 static int read_cim_ibq(struct cudbg_init *, struct cudbg_buffer *,
256 			struct cudbg_error * , int);
257 static int read_cim_obq(struct cudbg_init *, struct cudbg_buffer *,
258 			struct cudbg_error *, int);
259 int get_entity_hdr(void *outbuf, int i, u32 size, struct cudbg_entity_hdr **);
260 void skip_entity(int entity_code);
261 void reset_skip_entity(void);
262 int is_large_entity(int entity_code);
263 #endif
264