1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  *  Copyright (C) 2017 Chelsio Communications.  All rights reserved.
4  */
5 
6 #ifndef __CUDBG_LIB_H__
7 #define __CUDBG_LIB_H__
8 
9 int cudbg_collect_reg_dump(struct cudbg_init *pdbg_init,
10 			   struct cudbg_buffer *dbg_buff,
11 			   struct cudbg_error *cudbg_err);
12 int cudbg_collect_fw_devlog(struct cudbg_init *pdbg_init,
13 			    struct cudbg_buffer *dbg_buff,
14 			    struct cudbg_error *cudbg_err);
15 int cudbg_collect_cim_la(struct cudbg_init *pdbg_init,
16 			 struct cudbg_buffer *dbg_buff,
17 			 struct cudbg_error *cudbg_err);
18 int cudbg_collect_cim_ma_la(struct cudbg_init *pdbg_init,
19 			    struct cudbg_buffer *dbg_buff,
20 			    struct cudbg_error *cudbg_err);
21 int cudbg_collect_cim_qcfg(struct cudbg_init *pdbg_init,
22 			   struct cudbg_buffer *dbg_buff,
23 			   struct cudbg_error *cudbg_err);
24 int cudbg_collect_cim_ibq_tp0(struct cudbg_init *pdbg_init,
25 			      struct cudbg_buffer *dbg_buff,
26 			      struct cudbg_error *cudbg_err);
27 int cudbg_collect_cim_ibq_tp1(struct cudbg_init *pdbg_init,
28 			      struct cudbg_buffer *dbg_buff,
29 			      struct cudbg_error *cudbg_err);
30 int cudbg_collect_cim_ibq_ulp(struct cudbg_init *pdbg_init,
31 			      struct cudbg_buffer *dbg_buff,
32 			      struct cudbg_error *cudbg_err);
33 int cudbg_collect_cim_ibq_sge0(struct cudbg_init *pdbg_init,
34 			       struct cudbg_buffer *dbg_buff,
35 			       struct cudbg_error *cudbg_err);
36 int cudbg_collect_cim_ibq_sge1(struct cudbg_init *pdbg_init,
37 			       struct cudbg_buffer *dbg_buff,
38 			       struct cudbg_error *cudbg_err);
39 int cudbg_collect_cim_ibq_ncsi(struct cudbg_init *pdbg_init,
40 			       struct cudbg_buffer *dbg_buff,
41 			       struct cudbg_error *cudbg_err);
42 int cudbg_collect_cim_obq_ulp0(struct cudbg_init *pdbg_init,
43 			       struct cudbg_buffer *dbg_buff,
44 			       struct cudbg_error *cudbg_err);
45 int cudbg_collect_cim_obq_ulp1(struct cudbg_init *pdbg_init,
46 			       struct cudbg_buffer *dbg_buff,
47 			       struct cudbg_error *cudbg_err);
48 int cudbg_collect_cim_obq_ulp2(struct cudbg_init *pdbg_init,
49 			       struct cudbg_buffer *dbg_buff,
50 			       struct cudbg_error *cudbg_err);
51 int cudbg_collect_cim_obq_ulp3(struct cudbg_init *pdbg_init,
52 			       struct cudbg_buffer *dbg_buff,
53 			       struct cudbg_error *cudbg_err);
54 int cudbg_collect_cim_obq_sge(struct cudbg_init *pdbg_init,
55 			      struct cudbg_buffer *dbg_buff,
56 			      struct cudbg_error *cudbg_err);
57 int cudbg_collect_cim_obq_ncsi(struct cudbg_init *pdbg_init,
58 			       struct cudbg_buffer *dbg_buff,
59 			       struct cudbg_error *cudbg_err);
60 int cudbg_collect_edc0_meminfo(struct cudbg_init *pdbg_init,
61 			       struct cudbg_buffer *dbg_buff,
62 			       struct cudbg_error *cudbg_err);
63 int cudbg_collect_edc1_meminfo(struct cudbg_init *pdbg_init,
64 			       struct cudbg_buffer *dbg_buff,
65 			       struct cudbg_error *cudbg_err);
66 int cudbg_collect_mc0_meminfo(struct cudbg_init *pdbg_init,
67 			      struct cudbg_buffer *dbg_buff,
68 			      struct cudbg_error *cudbg_err);
69 int cudbg_collect_mc1_meminfo(struct cudbg_init *pdbg_init,
70 			      struct cudbg_buffer *dbg_buff,
71 			      struct cudbg_error *cudbg_err);
72 int cudbg_collect_rss(struct cudbg_init *pdbg_init,
73 		      struct cudbg_buffer *dbg_buff,
74 		      struct cudbg_error *cudbg_err);
75 int cudbg_collect_rss_vf_config(struct cudbg_init *pdbg_init,
76 				struct cudbg_buffer *dbg_buff,
77 				struct cudbg_error *cudbg_err);
78 int cudbg_collect_tp_indirect(struct cudbg_init *pdbg_init,
79 			      struct cudbg_buffer *dbg_buff,
80 			      struct cudbg_error *cudbg_err);
81 int cudbg_collect_path_mtu(struct cudbg_init *pdbg_init,
82 			   struct cudbg_buffer *dbg_buff,
83 			   struct cudbg_error *cudbg_err);
84 int cudbg_collect_pm_stats(struct cudbg_init *pdbg_init,
85 			   struct cudbg_buffer *dbg_buff,
86 			   struct cudbg_error *cudbg_err);
87 int cudbg_collect_hw_sched(struct cudbg_init *pdbg_init,
88 			   struct cudbg_buffer *dbg_buff,
89 			   struct cudbg_error *cudbg_err);
90 int cudbg_collect_sge_indirect(struct cudbg_init *pdbg_init,
91 			       struct cudbg_buffer *dbg_buff,
92 			       struct cudbg_error *cudbg_err);
93 int cudbg_collect_ulprx_la(struct cudbg_init *pdbg_init,
94 			   struct cudbg_buffer *dbg_buff,
95 			   struct cudbg_error *cudbg_err);
96 int cudbg_collect_tp_la(struct cudbg_init *pdbg_init,
97 			struct cudbg_buffer *dbg_buff,
98 			struct cudbg_error *cudbg_err);
99 int cudbg_collect_meminfo(struct cudbg_init *pdbg_init,
100 			  struct cudbg_buffer *dbg_buff,
101 			  struct cudbg_error *cudbg_err);
102 int cudbg_collect_cim_pif_la(struct cudbg_init *pdbg_init,
103 			     struct cudbg_buffer *dbg_buff,
104 			     struct cudbg_error *cudbg_err);
105 int cudbg_collect_clk_info(struct cudbg_init *pdbg_init,
106 			   struct cudbg_buffer *dbg_buff,
107 			   struct cudbg_error *cudbg_err);
108 int cudbg_collect_obq_sge_rx_q0(struct cudbg_init *pdbg_init,
109 				struct cudbg_buffer *dbg_buff,
110 				struct cudbg_error *cudbg_err);
111 int cudbg_collect_obq_sge_rx_q1(struct cudbg_init *pdbg_init,
112 				struct cudbg_buffer *dbg_buff,
113 				struct cudbg_error *cudbg_err);
114 int cudbg_collect_pcie_indirect(struct cudbg_init *pdbg_init,
115 				struct cudbg_buffer *dbg_buff,
116 				struct cudbg_error *cudbg_err);
117 int cudbg_collect_pm_indirect(struct cudbg_init *pdbg_init,
118 			      struct cudbg_buffer *dbg_buff,
119 			      struct cudbg_error *cudbg_err);
120 int cudbg_collect_tid(struct cudbg_init *pdbg_init,
121 		      struct cudbg_buffer *dbg_buff,
122 		      struct cudbg_error *cudbg_err);
123 int cudbg_collect_pcie_config(struct cudbg_init *pdbg_init,
124 			      struct cudbg_buffer *dbg_buff,
125 			      struct cudbg_error *cudbg_err);
126 int cudbg_collect_dump_context(struct cudbg_init *pdbg_init,
127 			       struct cudbg_buffer *dbg_buff,
128 			       struct cudbg_error *cudbg_err);
129 int cudbg_collect_mps_tcam(struct cudbg_init *pdbg_init,
130 			   struct cudbg_buffer *dbg_buff,
131 			   struct cudbg_error *cudbg_err);
132 int cudbg_collect_vpd_data(struct cudbg_init *pdbg_init,
133 			   struct cudbg_buffer *dbg_buff,
134 			   struct cudbg_error *cudbg_err);
135 int cudbg_collect_le_tcam(struct cudbg_init *pdbg_init,
136 			  struct cudbg_buffer *dbg_buff,
137 			  struct cudbg_error *cudbg_err);
138 int cudbg_collect_cctrl(struct cudbg_init *pdbg_init,
139 			struct cudbg_buffer *dbg_buff,
140 			struct cudbg_error *cudbg_err);
141 int cudbg_collect_ma_indirect(struct cudbg_init *pdbg_init,
142 			      struct cudbg_buffer *dbg_buff,
143 			      struct cudbg_error *cudbg_err);
144 int cudbg_collect_ulptx_la(struct cudbg_init *pdbg_init,
145 			   struct cudbg_buffer *dbg_buff,
146 			   struct cudbg_error *cudbg_err);
147 int cudbg_collect_up_cim_indirect(struct cudbg_init *pdbg_init,
148 				  struct cudbg_buffer *dbg_buff,
149 				  struct cudbg_error *cudbg_err);
150 int cudbg_collect_pbt_tables(struct cudbg_init *pdbg_init,
151 			     struct cudbg_buffer *dbg_buff,
152 			     struct cudbg_error *cudbg_err);
153 int cudbg_collect_mbox_log(struct cudbg_init *pdbg_init,
154 			   struct cudbg_buffer *dbg_buff,
155 			   struct cudbg_error *cudbg_err);
156 int cudbg_collect_hma_indirect(struct cudbg_init *pdbg_init,
157 			       struct cudbg_buffer *dbg_buff,
158 			       struct cudbg_error *cudbg_err);
159 int cudbg_collect_hma_meminfo(struct cudbg_init *pdbg_init,
160 			      struct cudbg_buffer *dbg_buff,
161 			      struct cudbg_error *cudbg_err);
162 int cudbg_collect_qdesc(struct cudbg_init *pdbg_init,
163 			struct cudbg_buffer *dbg_buff,
164 			struct cudbg_error *cudbg_err);
165 int cudbg_collect_flash(struct cudbg_init *pdbg_init,
166 			struct cudbg_buffer *dbg_buff,
167 			struct cudbg_error *cudbg_err);
168 
169 u32 cudbg_get_entity_length(struct adapter *adap, u32 entity);
170 struct cudbg_entity_hdr *cudbg_get_entity_hdr(void *outbuf, int i);
171 void cudbg_align_debug_buffer(struct cudbg_buffer *dbg_buff,
172 			      struct cudbg_entity_hdr *entity_hdr);
173 u32 cudbg_cim_obq_size(struct adapter *padap, int qid);
174 int cudbg_dump_context_size(struct adapter *padap);
175 
176 int cudbg_fill_meminfo(struct adapter *padap,
177 		       struct cudbg_meminfo *meminfo_buff);
178 void cudbg_fill_le_tcam_info(struct adapter *padap,
179 			     struct cudbg_tcam *tcam_region);
180 void cudbg_fill_qdesc_num_and_size(const struct adapter *padap,
181 				   u32 *num, u32 *size);
182 
183 static inline u32 cudbg_uld_txq_to_qtype(u32 uld)
184 {
185 	switch (uld) {
186 	case CXGB4_TX_OFLD:
187 		return CUDBG_QTYPE_OFLD_TXQ;
188 	case CXGB4_TX_CRYPTO:
189 		return CUDBG_QTYPE_CRYPTO_TXQ;
190 	}
191 
192 	return CUDBG_QTYPE_UNKNOWN;
193 }
194 
195 static inline u32 cudbg_uld_rxq_to_qtype(u32 uld)
196 {
197 	switch (uld) {
198 	case CXGB4_ULD_RDMA:
199 		return CUDBG_QTYPE_RDMA_RXQ;
200 	case CXGB4_ULD_ISCSI:
201 		return CUDBG_QTYPE_ISCSI_RXQ;
202 	case CXGB4_ULD_ISCSIT:
203 		return CUDBG_QTYPE_ISCSIT_RXQ;
204 	case CXGB4_ULD_CRYPTO:
205 		return CUDBG_QTYPE_CRYPTO_RXQ;
206 	case CXGB4_ULD_TLS:
207 		return CUDBG_QTYPE_TLS_RXQ;
208 	}
209 
210 	return CUDBG_QTYPE_UNKNOWN;
211 }
212 
213 static inline u32 cudbg_uld_flq_to_qtype(u32 uld)
214 {
215 	switch (uld) {
216 	case CXGB4_ULD_RDMA:
217 		return CUDBG_QTYPE_RDMA_FLQ;
218 	case CXGB4_ULD_ISCSI:
219 		return CUDBG_QTYPE_ISCSI_FLQ;
220 	case CXGB4_ULD_ISCSIT:
221 		return CUDBG_QTYPE_ISCSIT_FLQ;
222 	case CXGB4_ULD_CRYPTO:
223 		return CUDBG_QTYPE_CRYPTO_FLQ;
224 	case CXGB4_ULD_TLS:
225 		return CUDBG_QTYPE_TLS_FLQ;
226 	}
227 
228 	return CUDBG_QTYPE_UNKNOWN;
229 }
230 
231 static inline u32 cudbg_uld_ciq_to_qtype(u32 uld)
232 {
233 	switch (uld) {
234 	case CXGB4_ULD_RDMA:
235 		return CUDBG_QTYPE_RDMA_CIQ;
236 	}
237 
238 	return CUDBG_QTYPE_UNKNOWN;
239 }
240 
241 static inline void cudbg_fill_qdesc_txq(const struct sge_txq *txq,
242 					enum cudbg_qdesc_qtype type,
243 					struct cudbg_qdesc_entry *entry)
244 {
245 	entry->qtype = type;
246 	entry->qid = txq->cntxt_id;
247 	entry->desc_size = sizeof(struct tx_desc);
248 	entry->num_desc = txq->size;
249 	entry->data_size = txq->size * sizeof(struct tx_desc);
250 	memcpy(entry->data, txq->desc, entry->data_size);
251 }
252 
253 static inline void cudbg_fill_qdesc_rxq(const struct sge_rspq *rxq,
254 					enum cudbg_qdesc_qtype type,
255 					struct cudbg_qdesc_entry *entry)
256 {
257 	entry->qtype = type;
258 	entry->qid = rxq->cntxt_id;
259 	entry->desc_size = rxq->iqe_len;
260 	entry->num_desc = rxq->size;
261 	entry->data_size = rxq->size * rxq->iqe_len;
262 	memcpy(entry->data, rxq->desc, entry->data_size);
263 }
264 
265 static inline void cudbg_fill_qdesc_flq(const struct sge_fl *flq,
266 					enum cudbg_qdesc_qtype type,
267 					struct cudbg_qdesc_entry *entry)
268 {
269 	entry->qtype = type;
270 	entry->qid = flq->cntxt_id;
271 	entry->desc_size = sizeof(__be64);
272 	entry->num_desc = flq->size;
273 	entry->data_size = flq->size * sizeof(__be64);
274 	memcpy(entry->data, flq->desc, entry->data_size);
275 }
276 
277 static inline
278 struct cudbg_qdesc_entry *cudbg_next_qdesc(struct cudbg_qdesc_entry *e)
279 {
280 	return (struct cudbg_qdesc_entry *)
281 	       ((u8 *)e + sizeof(*e) + e->data_size);
282 }
283 #endif /* __CUDBG_LIB_H__ */
284