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