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