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 */ 27 28 #ifndef __CUDBG_LIB_H__ 29 #define __CUDBG_LIB_H__ 30 31 #ifndef min_t 32 #define min_t(type, _a, _b) (((type)(_a) < (type)(_b)) ? (type)(_a) : (type)(_b)) 33 #endif 34 35 static int collect_reg_dump(struct cudbg_init *, struct cudbg_buffer *, 36 struct cudbg_error *); 37 static int collect_fw_devlog(struct cudbg_init *, struct cudbg_buffer *, 38 struct cudbg_error *); 39 static int collect_cim_qcfg(struct cudbg_init *, struct cudbg_buffer *, 40 struct cudbg_error *); 41 static int collect_cim_la(struct cudbg_init *, struct cudbg_buffer *, 42 struct cudbg_error *); 43 static int collect_cim_ma_la(struct cudbg_init *, struct cudbg_buffer *, 44 struct cudbg_error *); 45 static int collect_cim_obq_ulp0(struct cudbg_init *, struct cudbg_buffer *, 46 struct cudbg_error *); 47 static int collect_cim_obq_ulp1(struct cudbg_init *, struct cudbg_buffer *, 48 struct cudbg_error *); 49 static int collect_cim_obq_ulp2(struct cudbg_init *, struct cudbg_buffer *, 50 struct cudbg_error *); 51 static int collect_cim_obq_ulp3(struct cudbg_init *, struct cudbg_buffer *, 52 struct cudbg_error *); 53 static int collect_cim_obq_sge(struct cudbg_init *, struct cudbg_buffer *, 54 struct cudbg_error *); 55 static int collect_cim_obq_ncsi(struct cudbg_init *, struct cudbg_buffer *, 56 struct cudbg_error *); 57 static int collect_cim_ibq_tp0(struct cudbg_init *, struct cudbg_buffer *, 58 struct cudbg_error *); 59 static int collect_cim_ibq_tp1(struct cudbg_init *, struct cudbg_buffer *, 60 struct cudbg_error *); 61 static int collect_cim_ibq_ulp(struct cudbg_init *, struct cudbg_buffer *, 62 struct cudbg_error *); 63 static int collect_cim_ibq_sge0(struct cudbg_init *, struct cudbg_buffer *, 64 struct cudbg_error *); 65 static int collect_cim_ibq_sge1(struct cudbg_init *, struct cudbg_buffer *, 66 struct cudbg_error *); 67 static int collect_cim_ibq_ncsi(struct cudbg_init *, struct cudbg_buffer *, 68 struct cudbg_error *); 69 static int collect_edc0_meminfo(struct cudbg_init *, struct cudbg_buffer *, 70 struct cudbg_error *); 71 static int collect_edc1_meminfo(struct cudbg_init *, struct cudbg_buffer *, 72 struct cudbg_error *); 73 static int collect_mc0_meminfo(struct cudbg_init *, struct cudbg_buffer *, 74 struct cudbg_error *); 75 static int collect_mc1_meminfo(struct cudbg_init *, struct cudbg_buffer *, 76 struct cudbg_error *); 77 static int collect_rss(struct cudbg_init *, struct cudbg_buffer *, 78 struct cudbg_error *); 79 static int collect_rss_key(struct cudbg_init *, struct cudbg_buffer *, 80 struct cudbg_error *); 81 static int collect_rss_pf_config(struct cudbg_init *, struct cudbg_buffer *, 82 struct cudbg_error *); 83 static int collect_rss_vf_config(struct cudbg_init *, struct cudbg_buffer *, 84 struct cudbg_error *); 85 static int collect_rss_config(struct cudbg_init *, struct cudbg_buffer *, 86 struct cudbg_error *); 87 static int collect_path_mtu(struct cudbg_init *, struct cudbg_buffer *, 88 struct cudbg_error *); 89 static int collect_sw_state(struct cudbg_init *, struct cudbg_buffer *, 90 struct cudbg_error *); 91 int collect_wtp_data(struct cudbg_init *, struct cudbg_buffer *, 92 struct cudbg_error *); 93 static int collect_pm_stats(struct cudbg_init *, struct cudbg_buffer *, 94 struct cudbg_error *); 95 static int collect_hw_sched(struct cudbg_init *, struct cudbg_buffer *, 96 struct cudbg_error *); 97 static int collect_tcp_stats(struct cudbg_init *, struct cudbg_buffer *, 98 struct cudbg_error *); 99 static int collect_tp_err_stats(struct cudbg_init *, struct cudbg_buffer *, 100 struct cudbg_error *); 101 static int collect_fcoe_stats(struct cudbg_init *, struct cudbg_buffer *, 102 struct cudbg_error *); 103 static int collect_rdma_stats(struct cudbg_init *, struct cudbg_buffer *, 104 struct cudbg_error *); 105 static int collect_tp_indirect(struct cudbg_init *, struct cudbg_buffer *, 106 struct cudbg_error *); 107 static int collect_sge_indirect(struct cudbg_init *, struct cudbg_buffer *, 108 struct cudbg_error *); 109 static int collect_cpl_stats(struct cudbg_init *, struct cudbg_buffer *, 110 struct cudbg_error *); 111 static int collect_ddp_stats(struct cudbg_init *, struct cudbg_buffer *, 112 struct cudbg_error *); 113 static int collect_wc_stats(struct cudbg_init *, struct cudbg_buffer *, 114 struct cudbg_error *); 115 static int collect_ulprx_la(struct cudbg_init *, struct cudbg_buffer *, 116 struct cudbg_error *); 117 static int collect_lb_stats(struct cudbg_init *, struct cudbg_buffer *, 118 struct cudbg_error *); 119 static int collect_tp_la(struct cudbg_init *, struct cudbg_buffer *, 120 struct cudbg_error *); 121 static int collect_meminfo(struct cudbg_init *, struct cudbg_buffer *, 122 struct cudbg_error *); 123 static int collect_cim_pif_la(struct cudbg_init *, struct cudbg_buffer *, 124 struct cudbg_error *); 125 static int collect_clk_info(struct cudbg_init *, struct cudbg_buffer *, 126 struct cudbg_error *); 127 static int collect_obq_sge_rx_q0(struct cudbg_init *, struct cudbg_buffer *, 128 struct cudbg_error *); 129 static int collect_obq_sge_rx_q1(struct cudbg_init *, struct cudbg_buffer *, 130 struct cudbg_error *); 131 static int collect_macstats(struct cudbg_init *, struct cudbg_buffer *, 132 struct cudbg_error *); 133 static int collect_pcie_indirect(struct cudbg_init *, struct cudbg_buffer *, 134 struct cudbg_error *); 135 static int collect_pm_indirect(struct cudbg_init *, struct cudbg_buffer *, 136 struct cudbg_error *); 137 static int collect_full(struct cudbg_init *, struct cudbg_buffer *, 138 struct cudbg_error *); 139 static int collect_tx_rate(struct cudbg_init *, struct cudbg_buffer *, 140 struct cudbg_error *); 141 static int collect_tid(struct cudbg_init *, struct cudbg_buffer *, 142 struct cudbg_error *); 143 static int collect_pcie_config(struct cudbg_init *, struct cudbg_buffer *, 144 struct cudbg_error *); 145 static int collect_dump_context(struct cudbg_init *, struct cudbg_buffer *, 146 struct cudbg_error *); 147 static int collect_mps_tcam(struct cudbg_init *, struct cudbg_buffer *, 148 struct cudbg_error *); 149 static int collect_vpd_data(struct cudbg_init *, struct cudbg_buffer *, 150 struct cudbg_error *); 151 static int collect_le_tcam(struct cudbg_init *, struct cudbg_buffer *, 152 struct cudbg_error *); 153 static int collect_cctrl(struct cudbg_init *, struct cudbg_buffer *, 154 struct cudbg_error *); 155 static int collect_ma_indirect(struct cudbg_init *, struct cudbg_buffer *, 156 struct cudbg_error *); 157 static int collect_ulptx_la(struct cudbg_init *, struct cudbg_buffer *, 158 struct cudbg_error *); 159 static int collect_up_cim_indirect(struct cudbg_init *, struct cudbg_buffer *, 160 struct cudbg_error *); 161 static int collect_pbt_tables(struct cudbg_init *, struct cudbg_buffer *, 162 struct cudbg_error *); 163 static int collect_mbox_log(struct cudbg_init *, struct cudbg_buffer *, 164 struct cudbg_error *); 165 static int collect_hma_indirect(struct cudbg_init *, struct cudbg_buffer *, 166 struct cudbg_error *); 167 168 static int (*process_entity[]) 169 (struct cudbg_init *, struct cudbg_buffer *, struct cudbg_error *) = { 170 collect_reg_dump, 171 collect_fw_devlog, 172 collect_cim_la, /*3*/ 173 collect_cim_ma_la, 174 collect_cim_qcfg, 175 collect_cim_ibq_tp0, 176 collect_cim_ibq_tp1, 177 collect_cim_ibq_ulp, 178 collect_cim_ibq_sge0, 179 collect_cim_ibq_sge1, 180 collect_cim_ibq_ncsi, 181 collect_cim_obq_ulp0, 182 collect_cim_obq_ulp1, /*13*/ 183 collect_cim_obq_ulp2, 184 collect_cim_obq_ulp3, 185 collect_cim_obq_sge, 186 collect_cim_obq_ncsi, 187 collect_edc0_meminfo, 188 collect_edc1_meminfo, 189 collect_mc0_meminfo, 190 collect_mc1_meminfo, 191 collect_rss, /*22*/ 192 collect_rss_pf_config, 193 collect_rss_key, 194 collect_rss_vf_config, 195 collect_rss_config, /*26*/ 196 collect_path_mtu, /*27*/ 197 collect_sw_state, 198 collect_wtp_data, 199 collect_pm_stats, 200 collect_hw_sched, 201 collect_tcp_stats, 202 collect_tp_err_stats, 203 collect_fcoe_stats, 204 collect_rdma_stats, 205 collect_tp_indirect, 206 collect_sge_indirect, 207 collect_cpl_stats, 208 collect_ddp_stats, 209 collect_wc_stats, 210 collect_ulprx_la, 211 collect_lb_stats, 212 collect_tp_la, 213 collect_meminfo, 214 collect_cim_pif_la, 215 collect_clk_info, 216 collect_obq_sge_rx_q0, 217 collect_obq_sge_rx_q1, 218 collect_macstats, 219 collect_pcie_indirect, 220 collect_pm_indirect, 221 collect_full, 222 collect_tx_rate, 223 collect_tid, 224 collect_pcie_config, 225 collect_dump_context, 226 collect_mps_tcam, 227 collect_vpd_data, 228 collect_le_tcam, 229 collect_cctrl, 230 collect_ma_indirect, 231 collect_ulptx_la, 232 NULL, /* ext entity */ 233 collect_up_cim_indirect, 234 collect_pbt_tables, 235 collect_mbox_log, 236 collect_hma_indirect, 237 }; 238 239 struct large_entity { 240 int entity_code; 241 int skip_flag; 242 int priority; /* 1 is high priority */ 243 }; 244 245 static int read_cim_ibq(struct cudbg_init *, struct cudbg_buffer *, 246 struct cudbg_error * , int); 247 static int read_cim_obq(struct cudbg_init *, struct cudbg_buffer *, 248 struct cudbg_error *, int); 249 int get_entity_hdr(void *outbuf, int i, u32 size, struct cudbg_entity_hdr **); 250 void skip_entity(int entity_code); 251 void reset_skip_entity(void); 252 int is_large_entity(int entity_code); 253 #endif 254