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) 2019 by Chelsio Communications, Inc.
14 */
15
16#ifndef __CUDBG_VIEW_H__
17#define __CUDBG_VIEW_H__
18
19#include "t4_hw.h"
20#include "cudbg_lib_common.h"
21
22#if defined(WIN32) || defined(__NT__) || defined(_WIN32) || defined(__WIN32__)
23typedef boolean_t bool;
24#endif
25
26#define DECLARE_VIEW_FUNC(FOO)				\
27	int view_##FOO(char *, struct cudbg_entity_hdr *, \
28 		     struct cudbg_buffer *, enum chip_type);
29DECLARE_VIEW_FUNC(cim_q);
30DECLARE_VIEW_FUNC(cim_la);
31DECLARE_VIEW_FUNC(reg_dump);
32DECLARE_VIEW_FUNC(cim_qcfg);
33DECLARE_VIEW_FUNC(mc0_data);
34DECLARE_VIEW_FUNC(mc1_data);
35DECLARE_VIEW_FUNC(fw_devlog);
36DECLARE_VIEW_FUNC(cim_ma_la);
37DECLARE_VIEW_FUNC(edc0_data);
38DECLARE_VIEW_FUNC(edc1_data);
39DECLARE_VIEW_FUNC(rss);
40DECLARE_VIEW_FUNC(rss_pf_config);
41DECLARE_VIEW_FUNC(rss_key);
42DECLARE_VIEW_FUNC(rss_vf_config);
43DECLARE_VIEW_FUNC(rss_config);
44DECLARE_VIEW_FUNC(path_mtu);
45DECLARE_VIEW_FUNC(sw_state);
46DECLARE_VIEW_FUNC(wtp);
47DECLARE_VIEW_FUNC(pm_stats);
48DECLARE_VIEW_FUNC(tcp_stats);
49DECLARE_VIEW_FUNC(hw_sched);
50DECLARE_VIEW_FUNC(tp_err_stats_show);
51DECLARE_VIEW_FUNC(fcoe_stats);
52DECLARE_VIEW_FUNC(rdma_stats);
53DECLARE_VIEW_FUNC(tp_indirect);
54DECLARE_VIEW_FUNC(sge_indirect);
55DECLARE_VIEW_FUNC(cpl_stats);
56DECLARE_VIEW_FUNC(ddp_stats);
57DECLARE_VIEW_FUNC(wc_stats);
58DECLARE_VIEW_FUNC(ulprx_la);
59DECLARE_VIEW_FUNC(lb_stats);
60DECLARE_VIEW_FUNC(tp_la);
61DECLARE_VIEW_FUNC(meminfo);
62DECLARE_VIEW_FUNC(cim_pif_la);
63DECLARE_VIEW_FUNC(clk_info);
64DECLARE_VIEW_FUNC(macstats);
65DECLARE_VIEW_FUNC(pcie_indirect);
66DECLARE_VIEW_FUNC(pm_indirect);
67DECLARE_VIEW_FUNC(full);
68DECLARE_VIEW_FUNC(tx_rate);
69DECLARE_VIEW_FUNC(tid);
70DECLARE_VIEW_FUNC(pcie_config);
71DECLARE_VIEW_FUNC(dump_context);
72DECLARE_VIEW_FUNC(mps_tcam);
73DECLARE_VIEW_FUNC(vpd_data);
74DECLARE_VIEW_FUNC(le_tcam);
75DECLARE_VIEW_FUNC(cctrl);
76DECLARE_VIEW_FUNC(ma_indirect);
77DECLARE_VIEW_FUNC(ulptx_la);
78DECLARE_VIEW_FUNC(ext_entity);
79DECLARE_VIEW_FUNC(up_cim_indirect);
80DECLARE_VIEW_FUNC(pbt_tables);
81DECLARE_VIEW_FUNC(mbox_log);
82DECLARE_VIEW_FUNC(hma_indirect);
83DECLARE_VIEW_FUNC(hma_data);
84DECLARE_VIEW_FUNC(upload);
85DECLARE_VIEW_FUNC(qdesc);
86
87static int (*view_entity[]) (char *, struct cudbg_entity_hdr *,
88			     struct cudbg_buffer *, enum chip_type) = {
89	view_reg_dump,
90	view_fw_devlog,
91	view_cim_la,
92	view_cim_ma_la,
93	view_cim_qcfg,
94	view_cim_q,
95	view_cim_q,
96	view_cim_q,
97	view_cim_q,
98	view_cim_q,
99	view_cim_q,
100	view_cim_q,
101	view_cim_q,
102	view_cim_q,
103	view_cim_q,
104	view_cim_q,
105	view_cim_q,
106	view_edc0_data,
107	view_edc1_data,
108	view_mc0_data,
109	view_mc1_data,
110	view_rss,	    /*22*/
111	view_rss_pf_config, /*23*/
112	view_rss_key,	    /*24*/
113	view_rss_vf_config,
114	view_rss_config,
115	view_path_mtu,
116	view_sw_state,
117	view_wtp,
118	view_pm_stats,
119	view_hw_sched,
120	view_tcp_stats,
121	view_tp_err_stats_show,
122	view_fcoe_stats,
123	view_rdma_stats,
124	view_tp_indirect,
125	view_sge_indirect,
126	view_cpl_stats,
127	view_ddp_stats,
128	view_wc_stats,
129	view_ulprx_la,
130	view_lb_stats,
131	view_tp_la,
132	view_meminfo,
133	view_cim_pif_la,
134	view_clk_info,
135	view_cim_q,
136	view_cim_q,
137	view_macstats,
138	view_pcie_indirect,
139	view_pm_indirect,
140	view_full,
141	view_tx_rate,
142	view_tid,
143	view_pcie_config,
144	view_dump_context,
145	view_mps_tcam,
146	view_vpd_data,
147	view_le_tcam,
148	view_cctrl,
149	view_ma_indirect,
150	view_ulptx_la,
151	view_ext_entity,
152	view_up_cim_indirect,
153	view_pbt_tables,
154	view_mbox_log,
155	view_hma_indirect,
156	view_hma_data,
157	view_upload,
158	view_qdesc,
159};
160
161struct reg_info {
162	const char *name;
163	uint32_t addr;
164	uint32_t len;
165};
166
167struct mod_regs {
168	const char *name;
169	const struct reg_info *ri;
170	unsigned int offset;
171};
172
173static const char *yesno(int);
174void translate_fw_devlog(void *, u32, u32 *, u32 *);
175#define BIT(n)	(1U << n)
176
177void cudbg_view_release_buff(char *pbuf, struct cudbg_buffer *dc_buff);
178void cudbg_print_flash_header(void *pinbuf);
179#endif
180