1a7975a2fSRahul Lakkireddy /* 2a7975a2fSRahul Lakkireddy * Copyright (C) 2017 Chelsio Communications. All rights reserved. 3a7975a2fSRahul Lakkireddy * 4a7975a2fSRahul Lakkireddy * This program is free software; you can redistribute it and/or modify it 5a7975a2fSRahul Lakkireddy * under the terms and conditions of the GNU General Public License, 6a7975a2fSRahul Lakkireddy * version 2, as published by the Free Software Foundation. 7a7975a2fSRahul Lakkireddy * 8a7975a2fSRahul Lakkireddy * This program is distributed in the hope it will be useful, but WITHOUT 9a7975a2fSRahul Lakkireddy * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10a7975a2fSRahul Lakkireddy * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11a7975a2fSRahul Lakkireddy * more details. 12a7975a2fSRahul Lakkireddy * 13a7975a2fSRahul Lakkireddy * The full GNU General Public License is included in this distribution in 14a7975a2fSRahul Lakkireddy * the file called "COPYING". 15a7975a2fSRahul Lakkireddy * 16a7975a2fSRahul Lakkireddy */ 17a7975a2fSRahul Lakkireddy 18b33af022SRahul Lakkireddy #include "t4_regs.h" 19a7975a2fSRahul Lakkireddy #include "cxgb4.h" 20a7975a2fSRahul Lakkireddy #include "cudbg_if.h" 21a7975a2fSRahul Lakkireddy #include "cudbg_lib_common.h" 22a7975a2fSRahul Lakkireddy #include "cudbg_lib.h" 23b33af022SRahul Lakkireddy #include "cudbg_entity.h" 24a7975a2fSRahul Lakkireddy 25a7975a2fSRahul Lakkireddy static void cudbg_write_and_release_buff(struct cudbg_buffer *pin_buff, 26a7975a2fSRahul Lakkireddy struct cudbg_buffer *dbg_buff) 27a7975a2fSRahul Lakkireddy { 28a7975a2fSRahul Lakkireddy cudbg_update_buff(pin_buff, dbg_buff); 29a7975a2fSRahul Lakkireddy cudbg_put_buff(pin_buff, dbg_buff); 30a7975a2fSRahul Lakkireddy } 31a7975a2fSRahul Lakkireddy 32b33af022SRahul Lakkireddy static int is_fw_attached(struct cudbg_init *pdbg_init) 33b33af022SRahul Lakkireddy { 34b33af022SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 35b33af022SRahul Lakkireddy 36b33af022SRahul Lakkireddy if (!(padap->flags & FW_OK) || padap->use_bd) 37b33af022SRahul Lakkireddy return 0; 38b33af022SRahul Lakkireddy 39b33af022SRahul Lakkireddy return 1; 40b33af022SRahul Lakkireddy } 41b33af022SRahul Lakkireddy 42a7975a2fSRahul Lakkireddy /* This function will add additional padding bytes into debug_buffer to make it 43a7975a2fSRahul Lakkireddy * 4 byte aligned. 44a7975a2fSRahul Lakkireddy */ 45a7975a2fSRahul Lakkireddy void cudbg_align_debug_buffer(struct cudbg_buffer *dbg_buff, 46a7975a2fSRahul Lakkireddy struct cudbg_entity_hdr *entity_hdr) 47a7975a2fSRahul Lakkireddy { 48a7975a2fSRahul Lakkireddy u8 zero_buf[4] = {0}; 49a7975a2fSRahul Lakkireddy u8 padding, remain; 50a7975a2fSRahul Lakkireddy 51a7975a2fSRahul Lakkireddy remain = (dbg_buff->offset - entity_hdr->start_offset) % 4; 52a7975a2fSRahul Lakkireddy padding = 4 - remain; 53a7975a2fSRahul Lakkireddy if (remain) { 54a7975a2fSRahul Lakkireddy memcpy(((u8 *)dbg_buff->data) + dbg_buff->offset, &zero_buf, 55a7975a2fSRahul Lakkireddy padding); 56a7975a2fSRahul Lakkireddy dbg_buff->offset += padding; 57a7975a2fSRahul Lakkireddy entity_hdr->num_pad = padding; 58a7975a2fSRahul Lakkireddy } 59a7975a2fSRahul Lakkireddy entity_hdr->size = dbg_buff->offset - entity_hdr->start_offset; 60a7975a2fSRahul Lakkireddy } 61a7975a2fSRahul Lakkireddy 62a7975a2fSRahul Lakkireddy struct cudbg_entity_hdr *cudbg_get_entity_hdr(void *outbuf, int i) 63a7975a2fSRahul Lakkireddy { 64a7975a2fSRahul Lakkireddy struct cudbg_hdr *cudbg_hdr = (struct cudbg_hdr *)outbuf; 65a7975a2fSRahul Lakkireddy 66a7975a2fSRahul Lakkireddy return (struct cudbg_entity_hdr *) 67a7975a2fSRahul Lakkireddy ((char *)outbuf + cudbg_hdr->hdr_len + 68a7975a2fSRahul Lakkireddy (sizeof(struct cudbg_entity_hdr) * (i - 1))); 69a7975a2fSRahul Lakkireddy } 70a7975a2fSRahul Lakkireddy 71a7975a2fSRahul Lakkireddy int cudbg_collect_reg_dump(struct cudbg_init *pdbg_init, 72a7975a2fSRahul Lakkireddy struct cudbg_buffer *dbg_buff, 73a7975a2fSRahul Lakkireddy struct cudbg_error *cudbg_err) 74a7975a2fSRahul Lakkireddy { 75a7975a2fSRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 76a7975a2fSRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 77a7975a2fSRahul Lakkireddy u32 buf_size = 0; 78a7975a2fSRahul Lakkireddy int rc = 0; 79a7975a2fSRahul Lakkireddy 80a7975a2fSRahul Lakkireddy if (is_t4(padap->params.chip)) 81a7975a2fSRahul Lakkireddy buf_size = T4_REGMAP_SIZE; 82a7975a2fSRahul Lakkireddy else if (is_t5(padap->params.chip) || is_t6(padap->params.chip)) 83a7975a2fSRahul Lakkireddy buf_size = T5_REGMAP_SIZE; 84a7975a2fSRahul Lakkireddy 85a7975a2fSRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, buf_size, &temp_buff); 86a7975a2fSRahul Lakkireddy if (rc) 87a7975a2fSRahul Lakkireddy return rc; 88a7975a2fSRahul Lakkireddy t4_get_regs(padap, (void *)temp_buff.data, temp_buff.size); 89a7975a2fSRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 90a7975a2fSRahul Lakkireddy return rc; 91a7975a2fSRahul Lakkireddy } 92b33af022SRahul Lakkireddy 93844d1b6fSRahul Lakkireddy int cudbg_collect_fw_devlog(struct cudbg_init *pdbg_init, 94844d1b6fSRahul Lakkireddy struct cudbg_buffer *dbg_buff, 95844d1b6fSRahul Lakkireddy struct cudbg_error *cudbg_err) 96844d1b6fSRahul Lakkireddy { 97844d1b6fSRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 98844d1b6fSRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 99844d1b6fSRahul Lakkireddy struct devlog_params *dparams; 100844d1b6fSRahul Lakkireddy int rc = 0; 101844d1b6fSRahul Lakkireddy 102844d1b6fSRahul Lakkireddy rc = t4_init_devlog_params(padap); 103844d1b6fSRahul Lakkireddy if (rc < 0) { 104844d1b6fSRahul Lakkireddy cudbg_err->sys_err = rc; 105844d1b6fSRahul Lakkireddy return rc; 106844d1b6fSRahul Lakkireddy } 107844d1b6fSRahul Lakkireddy 108844d1b6fSRahul Lakkireddy dparams = &padap->params.devlog; 109844d1b6fSRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, dparams->size, &temp_buff); 110844d1b6fSRahul Lakkireddy if (rc) 111844d1b6fSRahul Lakkireddy return rc; 112844d1b6fSRahul Lakkireddy 113844d1b6fSRahul Lakkireddy /* Collect FW devlog */ 114844d1b6fSRahul Lakkireddy if (dparams->start != 0) { 115844d1b6fSRahul Lakkireddy spin_lock(&padap->win0_lock); 116844d1b6fSRahul Lakkireddy rc = t4_memory_rw(padap, padap->params.drv_memwin, 117844d1b6fSRahul Lakkireddy dparams->memtype, dparams->start, 118844d1b6fSRahul Lakkireddy dparams->size, 119844d1b6fSRahul Lakkireddy (__be32 *)(char *)temp_buff.data, 120844d1b6fSRahul Lakkireddy 1); 121844d1b6fSRahul Lakkireddy spin_unlock(&padap->win0_lock); 122844d1b6fSRahul Lakkireddy if (rc) { 123844d1b6fSRahul Lakkireddy cudbg_err->sys_err = rc; 124844d1b6fSRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 125844d1b6fSRahul Lakkireddy return rc; 126844d1b6fSRahul Lakkireddy } 127844d1b6fSRahul Lakkireddy } 128844d1b6fSRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 129844d1b6fSRahul Lakkireddy return rc; 130844d1b6fSRahul Lakkireddy } 131844d1b6fSRahul Lakkireddy 13227887bc7SRahul Lakkireddy int cudbg_collect_cim_la(struct cudbg_init *pdbg_init, 13327887bc7SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 13427887bc7SRahul Lakkireddy struct cudbg_error *cudbg_err) 13527887bc7SRahul Lakkireddy { 13627887bc7SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 13727887bc7SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 13827887bc7SRahul Lakkireddy int size, rc; 13927887bc7SRahul Lakkireddy u32 cfg = 0; 14027887bc7SRahul Lakkireddy 14127887bc7SRahul Lakkireddy if (is_t6(padap->params.chip)) { 14227887bc7SRahul Lakkireddy size = padap->params.cim_la_size / 10 + 1; 14327887bc7SRahul Lakkireddy size *= 11 * sizeof(u32); 14427887bc7SRahul Lakkireddy } else { 14527887bc7SRahul Lakkireddy size = padap->params.cim_la_size / 8; 14627887bc7SRahul Lakkireddy size *= 8 * sizeof(u32); 14727887bc7SRahul Lakkireddy } 14827887bc7SRahul Lakkireddy 14927887bc7SRahul Lakkireddy size += sizeof(cfg); 15027887bc7SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, size, &temp_buff); 15127887bc7SRahul Lakkireddy if (rc) 15227887bc7SRahul Lakkireddy return rc; 15327887bc7SRahul Lakkireddy 15427887bc7SRahul Lakkireddy rc = t4_cim_read(padap, UP_UP_DBG_LA_CFG_A, 1, &cfg); 15527887bc7SRahul Lakkireddy if (rc) { 15627887bc7SRahul Lakkireddy cudbg_err->sys_err = rc; 15727887bc7SRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 15827887bc7SRahul Lakkireddy return rc; 15927887bc7SRahul Lakkireddy } 16027887bc7SRahul Lakkireddy 16127887bc7SRahul Lakkireddy memcpy((char *)temp_buff.data, &cfg, sizeof(cfg)); 16227887bc7SRahul Lakkireddy rc = t4_cim_read_la(padap, 16327887bc7SRahul Lakkireddy (u32 *)((char *)temp_buff.data + sizeof(cfg)), 16427887bc7SRahul Lakkireddy NULL); 16527887bc7SRahul Lakkireddy if (rc < 0) { 16627887bc7SRahul Lakkireddy cudbg_err->sys_err = rc; 16727887bc7SRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 16827887bc7SRahul Lakkireddy return rc; 16927887bc7SRahul Lakkireddy } 17027887bc7SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 17127887bc7SRahul Lakkireddy return rc; 17227887bc7SRahul Lakkireddy } 17327887bc7SRahul Lakkireddy 17427887bc7SRahul Lakkireddy int cudbg_collect_cim_ma_la(struct cudbg_init *pdbg_init, 17527887bc7SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 17627887bc7SRahul Lakkireddy struct cudbg_error *cudbg_err) 17727887bc7SRahul Lakkireddy { 17827887bc7SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 17927887bc7SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 18027887bc7SRahul Lakkireddy int size, rc; 18127887bc7SRahul Lakkireddy 18227887bc7SRahul Lakkireddy size = 2 * CIM_MALA_SIZE * 5 * sizeof(u32); 18327887bc7SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, size, &temp_buff); 18427887bc7SRahul Lakkireddy if (rc) 18527887bc7SRahul Lakkireddy return rc; 18627887bc7SRahul Lakkireddy 18727887bc7SRahul Lakkireddy t4_cim_read_ma_la(padap, 18827887bc7SRahul Lakkireddy (u32 *)temp_buff.data, 18927887bc7SRahul Lakkireddy (u32 *)((char *)temp_buff.data + 19027887bc7SRahul Lakkireddy 5 * CIM_MALA_SIZE)); 19127887bc7SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 19227887bc7SRahul Lakkireddy return rc; 19327887bc7SRahul Lakkireddy } 19427887bc7SRahul Lakkireddy 1953044d0fbSRahul Lakkireddy int cudbg_collect_cim_qcfg(struct cudbg_init *pdbg_init, 1963044d0fbSRahul Lakkireddy struct cudbg_buffer *dbg_buff, 1973044d0fbSRahul Lakkireddy struct cudbg_error *cudbg_err) 1983044d0fbSRahul Lakkireddy { 1993044d0fbSRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 2003044d0fbSRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 2013044d0fbSRahul Lakkireddy struct cudbg_cim_qcfg *cim_qcfg_data; 2023044d0fbSRahul Lakkireddy int rc; 2033044d0fbSRahul Lakkireddy 2043044d0fbSRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, sizeof(struct cudbg_cim_qcfg), 2053044d0fbSRahul Lakkireddy &temp_buff); 2063044d0fbSRahul Lakkireddy if (rc) 2073044d0fbSRahul Lakkireddy return rc; 2083044d0fbSRahul Lakkireddy 2093044d0fbSRahul Lakkireddy cim_qcfg_data = (struct cudbg_cim_qcfg *)temp_buff.data; 2103044d0fbSRahul Lakkireddy cim_qcfg_data->chip = padap->params.chip; 2113044d0fbSRahul Lakkireddy rc = t4_cim_read(padap, UP_IBQ_0_RDADDR_A, 2123044d0fbSRahul Lakkireddy ARRAY_SIZE(cim_qcfg_data->stat), cim_qcfg_data->stat); 2133044d0fbSRahul Lakkireddy if (rc) { 2143044d0fbSRahul Lakkireddy cudbg_err->sys_err = rc; 2153044d0fbSRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 2163044d0fbSRahul Lakkireddy return rc; 2173044d0fbSRahul Lakkireddy } 2183044d0fbSRahul Lakkireddy 2193044d0fbSRahul Lakkireddy rc = t4_cim_read(padap, UP_OBQ_0_REALADDR_A, 2203044d0fbSRahul Lakkireddy ARRAY_SIZE(cim_qcfg_data->obq_wr), 2213044d0fbSRahul Lakkireddy cim_qcfg_data->obq_wr); 2223044d0fbSRahul Lakkireddy if (rc) { 2233044d0fbSRahul Lakkireddy cudbg_err->sys_err = rc; 2243044d0fbSRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 2253044d0fbSRahul Lakkireddy return rc; 2263044d0fbSRahul Lakkireddy } 2273044d0fbSRahul Lakkireddy 2283044d0fbSRahul Lakkireddy t4_read_cimq_cfg(padap, cim_qcfg_data->base, cim_qcfg_data->size, 2293044d0fbSRahul Lakkireddy cim_qcfg_data->thres); 2303044d0fbSRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 2313044d0fbSRahul Lakkireddy return rc; 2323044d0fbSRahul Lakkireddy } 2333044d0fbSRahul Lakkireddy 2347c075ce2SRahul Lakkireddy static int cudbg_read_cim_ibq(struct cudbg_init *pdbg_init, 2357c075ce2SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 2367c075ce2SRahul Lakkireddy struct cudbg_error *cudbg_err, int qid) 2377c075ce2SRahul Lakkireddy { 2387c075ce2SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 2397c075ce2SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 2407c075ce2SRahul Lakkireddy int no_of_read_words, rc = 0; 2417c075ce2SRahul Lakkireddy u32 qsize; 2427c075ce2SRahul Lakkireddy 2437c075ce2SRahul Lakkireddy /* collect CIM IBQ */ 2447c075ce2SRahul Lakkireddy qsize = CIM_IBQ_SIZE * 4 * sizeof(u32); 2457c075ce2SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, qsize, &temp_buff); 2467c075ce2SRahul Lakkireddy if (rc) 2477c075ce2SRahul Lakkireddy return rc; 2487c075ce2SRahul Lakkireddy 2497c075ce2SRahul Lakkireddy /* t4_read_cim_ibq will return no. of read words or error */ 2507c075ce2SRahul Lakkireddy no_of_read_words = t4_read_cim_ibq(padap, qid, 251acfdf7eaSRahul Lakkireddy (u32 *)temp_buff.data, qsize); 2527c075ce2SRahul Lakkireddy /* no_of_read_words is less than or equal to 0 means error */ 2537c075ce2SRahul Lakkireddy if (no_of_read_words <= 0) { 2547c075ce2SRahul Lakkireddy if (!no_of_read_words) 2557c075ce2SRahul Lakkireddy rc = CUDBG_SYSTEM_ERROR; 2567c075ce2SRahul Lakkireddy else 2577c075ce2SRahul Lakkireddy rc = no_of_read_words; 2587c075ce2SRahul Lakkireddy cudbg_err->sys_err = rc; 2597c075ce2SRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 2607c075ce2SRahul Lakkireddy return rc; 2617c075ce2SRahul Lakkireddy } 2627c075ce2SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 2637c075ce2SRahul Lakkireddy return rc; 2647c075ce2SRahul Lakkireddy } 2657c075ce2SRahul Lakkireddy 2667c075ce2SRahul Lakkireddy int cudbg_collect_cim_ibq_tp0(struct cudbg_init *pdbg_init, 2677c075ce2SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 2687c075ce2SRahul Lakkireddy struct cudbg_error *cudbg_err) 2697c075ce2SRahul Lakkireddy { 2707c075ce2SRahul Lakkireddy return cudbg_read_cim_ibq(pdbg_init, dbg_buff, cudbg_err, 0); 2717c075ce2SRahul Lakkireddy } 2727c075ce2SRahul Lakkireddy 2737c075ce2SRahul Lakkireddy int cudbg_collect_cim_ibq_tp1(struct cudbg_init *pdbg_init, 2747c075ce2SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 2757c075ce2SRahul Lakkireddy struct cudbg_error *cudbg_err) 2767c075ce2SRahul Lakkireddy { 2777c075ce2SRahul Lakkireddy return cudbg_read_cim_ibq(pdbg_init, dbg_buff, cudbg_err, 1); 2787c075ce2SRahul Lakkireddy } 2797c075ce2SRahul Lakkireddy 2807c075ce2SRahul Lakkireddy int cudbg_collect_cim_ibq_ulp(struct cudbg_init *pdbg_init, 2817c075ce2SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 2827c075ce2SRahul Lakkireddy struct cudbg_error *cudbg_err) 2837c075ce2SRahul Lakkireddy { 2847c075ce2SRahul Lakkireddy return cudbg_read_cim_ibq(pdbg_init, dbg_buff, cudbg_err, 2); 2857c075ce2SRahul Lakkireddy } 2867c075ce2SRahul Lakkireddy 2877c075ce2SRahul Lakkireddy int cudbg_collect_cim_ibq_sge0(struct cudbg_init *pdbg_init, 2887c075ce2SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 2897c075ce2SRahul Lakkireddy struct cudbg_error *cudbg_err) 2907c075ce2SRahul Lakkireddy { 2917c075ce2SRahul Lakkireddy return cudbg_read_cim_ibq(pdbg_init, dbg_buff, cudbg_err, 3); 2927c075ce2SRahul Lakkireddy } 2937c075ce2SRahul Lakkireddy 2947c075ce2SRahul Lakkireddy int cudbg_collect_cim_ibq_sge1(struct cudbg_init *pdbg_init, 2957c075ce2SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 2967c075ce2SRahul Lakkireddy struct cudbg_error *cudbg_err) 2977c075ce2SRahul Lakkireddy { 2987c075ce2SRahul Lakkireddy return cudbg_read_cim_ibq(pdbg_init, dbg_buff, cudbg_err, 4); 2997c075ce2SRahul Lakkireddy } 3007c075ce2SRahul Lakkireddy 3017c075ce2SRahul Lakkireddy int cudbg_collect_cim_ibq_ncsi(struct cudbg_init *pdbg_init, 3027c075ce2SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 3037c075ce2SRahul Lakkireddy struct cudbg_error *cudbg_err) 3047c075ce2SRahul Lakkireddy { 3057c075ce2SRahul Lakkireddy return cudbg_read_cim_ibq(pdbg_init, dbg_buff, cudbg_err, 5); 3067c075ce2SRahul Lakkireddy } 3077c075ce2SRahul Lakkireddy 308acfdf7eaSRahul Lakkireddy u32 cudbg_cim_obq_size(struct adapter *padap, int qid) 309acfdf7eaSRahul Lakkireddy { 310acfdf7eaSRahul Lakkireddy u32 value; 311acfdf7eaSRahul Lakkireddy 312acfdf7eaSRahul Lakkireddy t4_write_reg(padap, CIM_QUEUE_CONFIG_REF_A, OBQSELECT_F | 313acfdf7eaSRahul Lakkireddy QUENUMSELECT_V(qid)); 314acfdf7eaSRahul Lakkireddy value = t4_read_reg(padap, CIM_QUEUE_CONFIG_CTRL_A); 315acfdf7eaSRahul Lakkireddy value = CIMQSIZE_G(value) * 64; /* size in number of words */ 316acfdf7eaSRahul Lakkireddy return value * sizeof(u32); 317acfdf7eaSRahul Lakkireddy } 318acfdf7eaSRahul Lakkireddy 3197c075ce2SRahul Lakkireddy static int cudbg_read_cim_obq(struct cudbg_init *pdbg_init, 3207c075ce2SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 3217c075ce2SRahul Lakkireddy struct cudbg_error *cudbg_err, int qid) 3227c075ce2SRahul Lakkireddy { 3237c075ce2SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 3247c075ce2SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 3257c075ce2SRahul Lakkireddy int no_of_read_words, rc = 0; 3267c075ce2SRahul Lakkireddy u32 qsize; 3277c075ce2SRahul Lakkireddy 3287c075ce2SRahul Lakkireddy /* collect CIM OBQ */ 329acfdf7eaSRahul Lakkireddy qsize = cudbg_cim_obq_size(padap, qid); 3307c075ce2SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, qsize, &temp_buff); 3317c075ce2SRahul Lakkireddy if (rc) 3327c075ce2SRahul Lakkireddy return rc; 3337c075ce2SRahul Lakkireddy 3347c075ce2SRahul Lakkireddy /* t4_read_cim_obq will return no. of read words or error */ 3357c075ce2SRahul Lakkireddy no_of_read_words = t4_read_cim_obq(padap, qid, 336acfdf7eaSRahul Lakkireddy (u32 *)temp_buff.data, qsize); 3377c075ce2SRahul Lakkireddy /* no_of_read_words is less than or equal to 0 means error */ 3387c075ce2SRahul Lakkireddy if (no_of_read_words <= 0) { 3397c075ce2SRahul Lakkireddy if (!no_of_read_words) 3407c075ce2SRahul Lakkireddy rc = CUDBG_SYSTEM_ERROR; 3417c075ce2SRahul Lakkireddy else 3427c075ce2SRahul Lakkireddy rc = no_of_read_words; 3437c075ce2SRahul Lakkireddy cudbg_err->sys_err = rc; 3447c075ce2SRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 3457c075ce2SRahul Lakkireddy return rc; 3467c075ce2SRahul Lakkireddy } 3477c075ce2SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 3487c075ce2SRahul Lakkireddy return rc; 3497c075ce2SRahul Lakkireddy } 3507c075ce2SRahul Lakkireddy 3517c075ce2SRahul Lakkireddy int cudbg_collect_cim_obq_ulp0(struct cudbg_init *pdbg_init, 3527c075ce2SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 3537c075ce2SRahul Lakkireddy struct cudbg_error *cudbg_err) 3547c075ce2SRahul Lakkireddy { 3557c075ce2SRahul Lakkireddy return cudbg_read_cim_obq(pdbg_init, dbg_buff, cudbg_err, 0); 3567c075ce2SRahul Lakkireddy } 3577c075ce2SRahul Lakkireddy 3587c075ce2SRahul Lakkireddy int cudbg_collect_cim_obq_ulp1(struct cudbg_init *pdbg_init, 3597c075ce2SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 3607c075ce2SRahul Lakkireddy struct cudbg_error *cudbg_err) 3617c075ce2SRahul Lakkireddy { 3627c075ce2SRahul Lakkireddy return cudbg_read_cim_obq(pdbg_init, dbg_buff, cudbg_err, 1); 3637c075ce2SRahul Lakkireddy } 3647c075ce2SRahul Lakkireddy 3657c075ce2SRahul Lakkireddy int cudbg_collect_cim_obq_ulp2(struct cudbg_init *pdbg_init, 3667c075ce2SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 3677c075ce2SRahul Lakkireddy struct cudbg_error *cudbg_err) 3687c075ce2SRahul Lakkireddy { 3697c075ce2SRahul Lakkireddy return cudbg_read_cim_obq(pdbg_init, dbg_buff, cudbg_err, 2); 3707c075ce2SRahul Lakkireddy } 3717c075ce2SRahul Lakkireddy 3727c075ce2SRahul Lakkireddy int cudbg_collect_cim_obq_ulp3(struct cudbg_init *pdbg_init, 3737c075ce2SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 3747c075ce2SRahul Lakkireddy struct cudbg_error *cudbg_err) 3757c075ce2SRahul Lakkireddy { 3767c075ce2SRahul Lakkireddy return cudbg_read_cim_obq(pdbg_init, dbg_buff, cudbg_err, 3); 3777c075ce2SRahul Lakkireddy } 3787c075ce2SRahul Lakkireddy 3797c075ce2SRahul Lakkireddy int cudbg_collect_cim_obq_sge(struct cudbg_init *pdbg_init, 3807c075ce2SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 3817c075ce2SRahul Lakkireddy struct cudbg_error *cudbg_err) 3827c075ce2SRahul Lakkireddy { 3837c075ce2SRahul Lakkireddy return cudbg_read_cim_obq(pdbg_init, dbg_buff, cudbg_err, 4); 3847c075ce2SRahul Lakkireddy } 3857c075ce2SRahul Lakkireddy 3867c075ce2SRahul Lakkireddy int cudbg_collect_cim_obq_ncsi(struct cudbg_init *pdbg_init, 3877c075ce2SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 3887c075ce2SRahul Lakkireddy struct cudbg_error *cudbg_err) 3897c075ce2SRahul Lakkireddy { 3907c075ce2SRahul Lakkireddy return cudbg_read_cim_obq(pdbg_init, dbg_buff, cudbg_err, 5); 3917c075ce2SRahul Lakkireddy } 3927c075ce2SRahul Lakkireddy 3937c075ce2SRahul Lakkireddy int cudbg_collect_obq_sge_rx_q0(struct cudbg_init *pdbg_init, 3947c075ce2SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 3957c075ce2SRahul Lakkireddy struct cudbg_error *cudbg_err) 3967c075ce2SRahul Lakkireddy { 3977c075ce2SRahul Lakkireddy return cudbg_read_cim_obq(pdbg_init, dbg_buff, cudbg_err, 6); 3987c075ce2SRahul Lakkireddy } 3997c075ce2SRahul Lakkireddy 4007c075ce2SRahul Lakkireddy int cudbg_collect_obq_sge_rx_q1(struct cudbg_init *pdbg_init, 4017c075ce2SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 4027c075ce2SRahul Lakkireddy struct cudbg_error *cudbg_err) 4037c075ce2SRahul Lakkireddy { 4047c075ce2SRahul Lakkireddy return cudbg_read_cim_obq(pdbg_init, dbg_buff, cudbg_err, 7); 4057c075ce2SRahul Lakkireddy } 4067c075ce2SRahul Lakkireddy 407b33af022SRahul Lakkireddy static int cudbg_read_fw_mem(struct cudbg_init *pdbg_init, 408b33af022SRahul Lakkireddy struct cudbg_buffer *dbg_buff, u8 mem_type, 409b33af022SRahul Lakkireddy unsigned long tot_len, 410b33af022SRahul Lakkireddy struct cudbg_error *cudbg_err) 411b33af022SRahul Lakkireddy { 412b33af022SRahul Lakkireddy unsigned long bytes, bytes_left, bytes_read = 0; 413b33af022SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 414b33af022SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 415b33af022SRahul Lakkireddy int rc = 0; 416b33af022SRahul Lakkireddy 417b33af022SRahul Lakkireddy bytes_left = tot_len; 418b33af022SRahul Lakkireddy while (bytes_left > 0) { 419b33af022SRahul Lakkireddy bytes = min_t(unsigned long, bytes_left, 420b33af022SRahul Lakkireddy (unsigned long)CUDBG_CHUNK_SIZE); 421b33af022SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, bytes, &temp_buff); 422b33af022SRahul Lakkireddy if (rc) 423b33af022SRahul Lakkireddy return rc; 424b33af022SRahul Lakkireddy spin_lock(&padap->win0_lock); 425b33af022SRahul Lakkireddy rc = t4_memory_rw(padap, MEMWIN_NIC, mem_type, 426b33af022SRahul Lakkireddy bytes_read, bytes, 427b33af022SRahul Lakkireddy (__be32 *)temp_buff.data, 428b33af022SRahul Lakkireddy 1); 429b33af022SRahul Lakkireddy spin_unlock(&padap->win0_lock); 430b33af022SRahul Lakkireddy if (rc) { 431b33af022SRahul Lakkireddy cudbg_err->sys_err = rc; 432b33af022SRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 433b33af022SRahul Lakkireddy return rc; 434b33af022SRahul Lakkireddy } 435b33af022SRahul Lakkireddy bytes_left -= bytes; 436b33af022SRahul Lakkireddy bytes_read += bytes; 437b33af022SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 438b33af022SRahul Lakkireddy } 439b33af022SRahul Lakkireddy return rc; 440b33af022SRahul Lakkireddy } 441b33af022SRahul Lakkireddy 442b33af022SRahul Lakkireddy static void cudbg_collect_mem_info(struct cudbg_init *pdbg_init, 443b33af022SRahul Lakkireddy struct card_mem *mem_info) 444b33af022SRahul Lakkireddy { 445b33af022SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 446b33af022SRahul Lakkireddy u32 value; 447b33af022SRahul Lakkireddy 448b33af022SRahul Lakkireddy value = t4_read_reg(padap, MA_EDRAM0_BAR_A); 449b33af022SRahul Lakkireddy value = EDRAM0_SIZE_G(value); 450b33af022SRahul Lakkireddy mem_info->size_edc0 = (u16)value; 451b33af022SRahul Lakkireddy 452b33af022SRahul Lakkireddy value = t4_read_reg(padap, MA_EDRAM1_BAR_A); 453b33af022SRahul Lakkireddy value = EDRAM1_SIZE_G(value); 454b33af022SRahul Lakkireddy mem_info->size_edc1 = (u16)value; 455b33af022SRahul Lakkireddy 456b33af022SRahul Lakkireddy value = t4_read_reg(padap, MA_TARGET_MEM_ENABLE_A); 457b33af022SRahul Lakkireddy if (value & EDRAM0_ENABLE_F) 458b33af022SRahul Lakkireddy mem_info->mem_flag |= (1 << EDC0_FLAG); 459b33af022SRahul Lakkireddy if (value & EDRAM1_ENABLE_F) 460b33af022SRahul Lakkireddy mem_info->mem_flag |= (1 << EDC1_FLAG); 461b33af022SRahul Lakkireddy } 462b33af022SRahul Lakkireddy 463b33af022SRahul Lakkireddy static void cudbg_t4_fwcache(struct cudbg_init *pdbg_init, 464b33af022SRahul Lakkireddy struct cudbg_error *cudbg_err) 465b33af022SRahul Lakkireddy { 466b33af022SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 467b33af022SRahul Lakkireddy int rc; 468b33af022SRahul Lakkireddy 469b33af022SRahul Lakkireddy if (is_fw_attached(pdbg_init)) { 470b33af022SRahul Lakkireddy /* Flush uP dcache before reading edcX/mcX */ 471b33af022SRahul Lakkireddy rc = t4_fwcache(padap, FW_PARAM_DEV_FWCACHE_FLUSH); 472b33af022SRahul Lakkireddy if (rc) 473b33af022SRahul Lakkireddy cudbg_err->sys_warn = rc; 474b33af022SRahul Lakkireddy } 475b33af022SRahul Lakkireddy } 476b33af022SRahul Lakkireddy 477b33af022SRahul Lakkireddy static int cudbg_collect_mem_region(struct cudbg_init *pdbg_init, 478b33af022SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 479b33af022SRahul Lakkireddy struct cudbg_error *cudbg_err, 480b33af022SRahul Lakkireddy u8 mem_type) 481b33af022SRahul Lakkireddy { 482b33af022SRahul Lakkireddy struct card_mem mem_info = {0}; 483b33af022SRahul Lakkireddy unsigned long flag, size; 484b33af022SRahul Lakkireddy int rc; 485b33af022SRahul Lakkireddy 486b33af022SRahul Lakkireddy cudbg_t4_fwcache(pdbg_init, cudbg_err); 487b33af022SRahul Lakkireddy cudbg_collect_mem_info(pdbg_init, &mem_info); 488b33af022SRahul Lakkireddy switch (mem_type) { 489b33af022SRahul Lakkireddy case MEM_EDC0: 490b33af022SRahul Lakkireddy flag = (1 << EDC0_FLAG); 491b33af022SRahul Lakkireddy size = cudbg_mbytes_to_bytes(mem_info.size_edc0); 492b33af022SRahul Lakkireddy break; 493b33af022SRahul Lakkireddy case MEM_EDC1: 494b33af022SRahul Lakkireddy flag = (1 << EDC1_FLAG); 495b33af022SRahul Lakkireddy size = cudbg_mbytes_to_bytes(mem_info.size_edc1); 496b33af022SRahul Lakkireddy break; 497b33af022SRahul Lakkireddy default: 498b33af022SRahul Lakkireddy rc = CUDBG_STATUS_ENTITY_NOT_FOUND; 499b33af022SRahul Lakkireddy goto err; 500b33af022SRahul Lakkireddy } 501b33af022SRahul Lakkireddy 502b33af022SRahul Lakkireddy if (mem_info.mem_flag & flag) { 503b33af022SRahul Lakkireddy rc = cudbg_read_fw_mem(pdbg_init, dbg_buff, mem_type, 504b33af022SRahul Lakkireddy size, cudbg_err); 505b33af022SRahul Lakkireddy if (rc) 506b33af022SRahul Lakkireddy goto err; 507b33af022SRahul Lakkireddy } else { 508b33af022SRahul Lakkireddy rc = CUDBG_STATUS_ENTITY_NOT_FOUND; 509b33af022SRahul Lakkireddy goto err; 510b33af022SRahul Lakkireddy } 511b33af022SRahul Lakkireddy err: 512b33af022SRahul Lakkireddy return rc; 513b33af022SRahul Lakkireddy } 514b33af022SRahul Lakkireddy 515b33af022SRahul Lakkireddy int cudbg_collect_edc0_meminfo(struct cudbg_init *pdbg_init, 516b33af022SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 517b33af022SRahul Lakkireddy struct cudbg_error *cudbg_err) 518b33af022SRahul Lakkireddy { 519b33af022SRahul Lakkireddy return cudbg_collect_mem_region(pdbg_init, dbg_buff, cudbg_err, 520b33af022SRahul Lakkireddy MEM_EDC0); 521b33af022SRahul Lakkireddy } 522b33af022SRahul Lakkireddy 523b33af022SRahul Lakkireddy int cudbg_collect_edc1_meminfo(struct cudbg_init *pdbg_init, 524b33af022SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 525b33af022SRahul Lakkireddy struct cudbg_error *cudbg_err) 526b33af022SRahul Lakkireddy { 527b33af022SRahul Lakkireddy return cudbg_collect_mem_region(pdbg_init, dbg_buff, cudbg_err, 528b33af022SRahul Lakkireddy MEM_EDC1); 529b33af022SRahul Lakkireddy } 530844d1b6fSRahul Lakkireddy 53128b44556SRahul Lakkireddy int cudbg_collect_rss(struct cudbg_init *pdbg_init, 53228b44556SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 53328b44556SRahul Lakkireddy struct cudbg_error *cudbg_err) 53428b44556SRahul Lakkireddy { 53528b44556SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 53628b44556SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 53728b44556SRahul Lakkireddy int rc; 53828b44556SRahul Lakkireddy 53928b44556SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, RSS_NENTRIES * sizeof(u16), &temp_buff); 54028b44556SRahul Lakkireddy if (rc) 54128b44556SRahul Lakkireddy return rc; 54228b44556SRahul Lakkireddy 54328b44556SRahul Lakkireddy rc = t4_read_rss(padap, (u16 *)temp_buff.data); 54428b44556SRahul Lakkireddy if (rc) { 54528b44556SRahul Lakkireddy cudbg_err->sys_err = rc; 54628b44556SRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 54728b44556SRahul Lakkireddy return rc; 54828b44556SRahul Lakkireddy } 54928b44556SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 55028b44556SRahul Lakkireddy return rc; 55128b44556SRahul Lakkireddy } 55228b44556SRahul Lakkireddy 55328b44556SRahul Lakkireddy int cudbg_collect_rss_vf_config(struct cudbg_init *pdbg_init, 55428b44556SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 55528b44556SRahul Lakkireddy struct cudbg_error *cudbg_err) 55628b44556SRahul Lakkireddy { 55728b44556SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 55828b44556SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 55928b44556SRahul Lakkireddy struct cudbg_rss_vf_conf *vfconf; 56028b44556SRahul Lakkireddy int vf, rc, vf_count; 56128b44556SRahul Lakkireddy 56228b44556SRahul Lakkireddy vf_count = padap->params.arch.vfcount; 56328b44556SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, 56428b44556SRahul Lakkireddy vf_count * sizeof(struct cudbg_rss_vf_conf), 56528b44556SRahul Lakkireddy &temp_buff); 56628b44556SRahul Lakkireddy if (rc) 56728b44556SRahul Lakkireddy return rc; 56828b44556SRahul Lakkireddy 56928b44556SRahul Lakkireddy vfconf = (struct cudbg_rss_vf_conf *)temp_buff.data; 57028b44556SRahul Lakkireddy for (vf = 0; vf < vf_count; vf++) 57128b44556SRahul Lakkireddy t4_read_rss_vf_config(padap, vf, &vfconf[vf].rss_vf_vfl, 57228b44556SRahul Lakkireddy &vfconf[vf].rss_vf_vfh, true); 57328b44556SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 57428b44556SRahul Lakkireddy return rc; 57528b44556SRahul Lakkireddy } 57628b44556SRahul Lakkireddy 5776f92a654SRahul Lakkireddy int cudbg_collect_path_mtu(struct cudbg_init *pdbg_init, 5786f92a654SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 5796f92a654SRahul Lakkireddy struct cudbg_error *cudbg_err) 5806f92a654SRahul Lakkireddy { 5816f92a654SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 5826f92a654SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 5836f92a654SRahul Lakkireddy int rc; 5846f92a654SRahul Lakkireddy 5856f92a654SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, NMTUS * sizeof(u16), &temp_buff); 5866f92a654SRahul Lakkireddy if (rc) 5876f92a654SRahul Lakkireddy return rc; 5886f92a654SRahul Lakkireddy 5896f92a654SRahul Lakkireddy t4_read_mtu_tbl(padap, (u16 *)temp_buff.data, NULL); 5906f92a654SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 5916f92a654SRahul Lakkireddy return rc; 5926f92a654SRahul Lakkireddy } 5936f92a654SRahul Lakkireddy 5946f92a654SRahul Lakkireddy int cudbg_collect_pm_stats(struct cudbg_init *pdbg_init, 5956f92a654SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 5966f92a654SRahul Lakkireddy struct cudbg_error *cudbg_err) 5976f92a654SRahul Lakkireddy { 5986f92a654SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 5996f92a654SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 6006f92a654SRahul Lakkireddy struct cudbg_pm_stats *pm_stats_buff; 6016f92a654SRahul Lakkireddy int rc; 6026f92a654SRahul Lakkireddy 6036f92a654SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, sizeof(struct cudbg_pm_stats), 6046f92a654SRahul Lakkireddy &temp_buff); 6056f92a654SRahul Lakkireddy if (rc) 6066f92a654SRahul Lakkireddy return rc; 6076f92a654SRahul Lakkireddy 6086f92a654SRahul Lakkireddy pm_stats_buff = (struct cudbg_pm_stats *)temp_buff.data; 6096f92a654SRahul Lakkireddy t4_pmtx_get_stats(padap, pm_stats_buff->tx_cnt, pm_stats_buff->tx_cyc); 6106f92a654SRahul Lakkireddy t4_pmrx_get_stats(padap, pm_stats_buff->rx_cnt, pm_stats_buff->rx_cyc); 6116f92a654SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 6126f92a654SRahul Lakkireddy return rc; 6136f92a654SRahul Lakkireddy } 6146f92a654SRahul Lakkireddy 61508c4901bSRahul Lakkireddy int cudbg_collect_hw_sched(struct cudbg_init *pdbg_init, 61608c4901bSRahul Lakkireddy struct cudbg_buffer *dbg_buff, 61708c4901bSRahul Lakkireddy struct cudbg_error *cudbg_err) 61808c4901bSRahul Lakkireddy { 61908c4901bSRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 62008c4901bSRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 62108c4901bSRahul Lakkireddy struct cudbg_hw_sched *hw_sched_buff; 62208c4901bSRahul Lakkireddy int i, rc = 0; 62308c4901bSRahul Lakkireddy 62408c4901bSRahul Lakkireddy if (!padap->params.vpd.cclk) 62508c4901bSRahul Lakkireddy return CUDBG_STATUS_CCLK_NOT_DEFINED; 62608c4901bSRahul Lakkireddy 62708c4901bSRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, sizeof(struct cudbg_hw_sched), 62808c4901bSRahul Lakkireddy &temp_buff); 62908c4901bSRahul Lakkireddy hw_sched_buff = (struct cudbg_hw_sched *)temp_buff.data; 63008c4901bSRahul Lakkireddy hw_sched_buff->map = t4_read_reg(padap, TP_TX_MOD_QUEUE_REQ_MAP_A); 63108c4901bSRahul Lakkireddy hw_sched_buff->mode = TIMERMODE_G(t4_read_reg(padap, TP_MOD_CONFIG_A)); 63208c4901bSRahul Lakkireddy t4_read_pace_tbl(padap, hw_sched_buff->pace_tab); 63308c4901bSRahul Lakkireddy for (i = 0; i < NTX_SCHED; ++i) 63408c4901bSRahul Lakkireddy t4_get_tx_sched(padap, i, &hw_sched_buff->kbps[i], 63508c4901bSRahul Lakkireddy &hw_sched_buff->ipg[i], true); 63608c4901bSRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 63708c4901bSRahul Lakkireddy return rc; 63808c4901bSRahul Lakkireddy } 63908c4901bSRahul Lakkireddy 6404359cf33SRahul Lakkireddy int cudbg_collect_tp_indirect(struct cudbg_init *pdbg_init, 6414359cf33SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 6424359cf33SRahul Lakkireddy struct cudbg_error *cudbg_err) 6434359cf33SRahul Lakkireddy { 6444359cf33SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 6454359cf33SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 6464359cf33SRahul Lakkireddy struct ireg_buf *ch_tp_pio; 6474359cf33SRahul Lakkireddy int i, rc, n = 0; 6484359cf33SRahul Lakkireddy u32 size; 6494359cf33SRahul Lakkireddy 6504359cf33SRahul Lakkireddy if (is_t5(padap->params.chip)) 6514359cf33SRahul Lakkireddy n = sizeof(t5_tp_pio_array) + 6524359cf33SRahul Lakkireddy sizeof(t5_tp_tm_pio_array) + 6534359cf33SRahul Lakkireddy sizeof(t5_tp_mib_index_array); 6544359cf33SRahul Lakkireddy else 6554359cf33SRahul Lakkireddy n = sizeof(t6_tp_pio_array) + 6564359cf33SRahul Lakkireddy sizeof(t6_tp_tm_pio_array) + 6574359cf33SRahul Lakkireddy sizeof(t6_tp_mib_index_array); 6584359cf33SRahul Lakkireddy 6594359cf33SRahul Lakkireddy n = n / (IREG_NUM_ELEM * sizeof(u32)); 6604359cf33SRahul Lakkireddy size = sizeof(struct ireg_buf) * n; 6614359cf33SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, size, &temp_buff); 6624359cf33SRahul Lakkireddy if (rc) 6634359cf33SRahul Lakkireddy return rc; 6644359cf33SRahul Lakkireddy 6654359cf33SRahul Lakkireddy ch_tp_pio = (struct ireg_buf *)temp_buff.data; 6664359cf33SRahul Lakkireddy 6674359cf33SRahul Lakkireddy /* TP_PIO */ 6684359cf33SRahul Lakkireddy if (is_t5(padap->params.chip)) 6694359cf33SRahul Lakkireddy n = sizeof(t5_tp_pio_array) / (IREG_NUM_ELEM * sizeof(u32)); 6704359cf33SRahul Lakkireddy else if (is_t6(padap->params.chip)) 6714359cf33SRahul Lakkireddy n = sizeof(t6_tp_pio_array) / (IREG_NUM_ELEM * sizeof(u32)); 6724359cf33SRahul Lakkireddy 6734359cf33SRahul Lakkireddy for (i = 0; i < n; i++) { 6744359cf33SRahul Lakkireddy struct ireg_field *tp_pio = &ch_tp_pio->tp_pio; 6754359cf33SRahul Lakkireddy u32 *buff = ch_tp_pio->outbuf; 6764359cf33SRahul Lakkireddy 6774359cf33SRahul Lakkireddy if (is_t5(padap->params.chip)) { 6784359cf33SRahul Lakkireddy tp_pio->ireg_addr = t5_tp_pio_array[i][0]; 6794359cf33SRahul Lakkireddy tp_pio->ireg_data = t5_tp_pio_array[i][1]; 6804359cf33SRahul Lakkireddy tp_pio->ireg_local_offset = t5_tp_pio_array[i][2]; 6814359cf33SRahul Lakkireddy tp_pio->ireg_offset_range = t5_tp_pio_array[i][3]; 6824359cf33SRahul Lakkireddy } else if (is_t6(padap->params.chip)) { 6834359cf33SRahul Lakkireddy tp_pio->ireg_addr = t6_tp_pio_array[i][0]; 6844359cf33SRahul Lakkireddy tp_pio->ireg_data = t6_tp_pio_array[i][1]; 6854359cf33SRahul Lakkireddy tp_pio->ireg_local_offset = t6_tp_pio_array[i][2]; 6864359cf33SRahul Lakkireddy tp_pio->ireg_offset_range = t6_tp_pio_array[i][3]; 6874359cf33SRahul Lakkireddy } 6884359cf33SRahul Lakkireddy t4_tp_pio_read(padap, buff, tp_pio->ireg_offset_range, 6894359cf33SRahul Lakkireddy tp_pio->ireg_local_offset, true); 6904359cf33SRahul Lakkireddy ch_tp_pio++; 6914359cf33SRahul Lakkireddy } 6924359cf33SRahul Lakkireddy 6934359cf33SRahul Lakkireddy /* TP_TM_PIO */ 6944359cf33SRahul Lakkireddy if (is_t5(padap->params.chip)) 6954359cf33SRahul Lakkireddy n = sizeof(t5_tp_tm_pio_array) / (IREG_NUM_ELEM * sizeof(u32)); 6964359cf33SRahul Lakkireddy else if (is_t6(padap->params.chip)) 6974359cf33SRahul Lakkireddy n = sizeof(t6_tp_tm_pio_array) / (IREG_NUM_ELEM * sizeof(u32)); 6984359cf33SRahul Lakkireddy 6994359cf33SRahul Lakkireddy for (i = 0; i < n; i++) { 7004359cf33SRahul Lakkireddy struct ireg_field *tp_pio = &ch_tp_pio->tp_pio; 7014359cf33SRahul Lakkireddy u32 *buff = ch_tp_pio->outbuf; 7024359cf33SRahul Lakkireddy 7034359cf33SRahul Lakkireddy if (is_t5(padap->params.chip)) { 7044359cf33SRahul Lakkireddy tp_pio->ireg_addr = t5_tp_tm_pio_array[i][0]; 7054359cf33SRahul Lakkireddy tp_pio->ireg_data = t5_tp_tm_pio_array[i][1]; 7064359cf33SRahul Lakkireddy tp_pio->ireg_local_offset = t5_tp_tm_pio_array[i][2]; 7074359cf33SRahul Lakkireddy tp_pio->ireg_offset_range = t5_tp_tm_pio_array[i][3]; 7084359cf33SRahul Lakkireddy } else if (is_t6(padap->params.chip)) { 7094359cf33SRahul Lakkireddy tp_pio->ireg_addr = t6_tp_tm_pio_array[i][0]; 7104359cf33SRahul Lakkireddy tp_pio->ireg_data = t6_tp_tm_pio_array[i][1]; 7114359cf33SRahul Lakkireddy tp_pio->ireg_local_offset = t6_tp_tm_pio_array[i][2]; 7124359cf33SRahul Lakkireddy tp_pio->ireg_offset_range = t6_tp_tm_pio_array[i][3]; 7134359cf33SRahul Lakkireddy } 7144359cf33SRahul Lakkireddy t4_tp_tm_pio_read(padap, buff, tp_pio->ireg_offset_range, 7154359cf33SRahul Lakkireddy tp_pio->ireg_local_offset, true); 7164359cf33SRahul Lakkireddy ch_tp_pio++; 7174359cf33SRahul Lakkireddy } 7184359cf33SRahul Lakkireddy 7194359cf33SRahul Lakkireddy /* TP_MIB_INDEX */ 7204359cf33SRahul Lakkireddy if (is_t5(padap->params.chip)) 7214359cf33SRahul Lakkireddy n = sizeof(t5_tp_mib_index_array) / 7224359cf33SRahul Lakkireddy (IREG_NUM_ELEM * sizeof(u32)); 7234359cf33SRahul Lakkireddy else if (is_t6(padap->params.chip)) 7244359cf33SRahul Lakkireddy n = sizeof(t6_tp_mib_index_array) / 7254359cf33SRahul Lakkireddy (IREG_NUM_ELEM * sizeof(u32)); 7264359cf33SRahul Lakkireddy 7274359cf33SRahul Lakkireddy for (i = 0; i < n ; i++) { 7284359cf33SRahul Lakkireddy struct ireg_field *tp_pio = &ch_tp_pio->tp_pio; 7294359cf33SRahul Lakkireddy u32 *buff = ch_tp_pio->outbuf; 7304359cf33SRahul Lakkireddy 7314359cf33SRahul Lakkireddy if (is_t5(padap->params.chip)) { 7324359cf33SRahul Lakkireddy tp_pio->ireg_addr = t5_tp_mib_index_array[i][0]; 7334359cf33SRahul Lakkireddy tp_pio->ireg_data = t5_tp_mib_index_array[i][1]; 7344359cf33SRahul Lakkireddy tp_pio->ireg_local_offset = 7354359cf33SRahul Lakkireddy t5_tp_mib_index_array[i][2]; 7364359cf33SRahul Lakkireddy tp_pio->ireg_offset_range = 7374359cf33SRahul Lakkireddy t5_tp_mib_index_array[i][3]; 7384359cf33SRahul Lakkireddy } else if (is_t6(padap->params.chip)) { 7394359cf33SRahul Lakkireddy tp_pio->ireg_addr = t6_tp_mib_index_array[i][0]; 7404359cf33SRahul Lakkireddy tp_pio->ireg_data = t6_tp_mib_index_array[i][1]; 7414359cf33SRahul Lakkireddy tp_pio->ireg_local_offset = 7424359cf33SRahul Lakkireddy t6_tp_mib_index_array[i][2]; 7434359cf33SRahul Lakkireddy tp_pio->ireg_offset_range = 7444359cf33SRahul Lakkireddy t6_tp_mib_index_array[i][3]; 7454359cf33SRahul Lakkireddy } 7464359cf33SRahul Lakkireddy t4_tp_mib_read(padap, buff, tp_pio->ireg_offset_range, 7474359cf33SRahul Lakkireddy tp_pio->ireg_local_offset, true); 7484359cf33SRahul Lakkireddy ch_tp_pio++; 7494359cf33SRahul Lakkireddy } 7504359cf33SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 7514359cf33SRahul Lakkireddy return rc; 7524359cf33SRahul Lakkireddy } 7534359cf33SRahul Lakkireddy 754270d39bfSRahul Lakkireddy int cudbg_collect_sge_indirect(struct cudbg_init *pdbg_init, 755270d39bfSRahul Lakkireddy struct cudbg_buffer *dbg_buff, 756270d39bfSRahul Lakkireddy struct cudbg_error *cudbg_err) 757270d39bfSRahul Lakkireddy { 758270d39bfSRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 759270d39bfSRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 760270d39bfSRahul Lakkireddy struct ireg_buf *ch_sge_dbg; 761270d39bfSRahul Lakkireddy int i, rc; 762270d39bfSRahul Lakkireddy 763270d39bfSRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, sizeof(*ch_sge_dbg) * 2, &temp_buff); 764270d39bfSRahul Lakkireddy if (rc) 765270d39bfSRahul Lakkireddy return rc; 766270d39bfSRahul Lakkireddy 767270d39bfSRahul Lakkireddy ch_sge_dbg = (struct ireg_buf *)temp_buff.data; 768270d39bfSRahul Lakkireddy for (i = 0; i < 2; i++) { 769270d39bfSRahul Lakkireddy struct ireg_field *sge_pio = &ch_sge_dbg->tp_pio; 770270d39bfSRahul Lakkireddy u32 *buff = ch_sge_dbg->outbuf; 771270d39bfSRahul Lakkireddy 772270d39bfSRahul Lakkireddy sge_pio->ireg_addr = t5_sge_dbg_index_array[i][0]; 773270d39bfSRahul Lakkireddy sge_pio->ireg_data = t5_sge_dbg_index_array[i][1]; 774270d39bfSRahul Lakkireddy sge_pio->ireg_local_offset = t5_sge_dbg_index_array[i][2]; 775270d39bfSRahul Lakkireddy sge_pio->ireg_offset_range = t5_sge_dbg_index_array[i][3]; 776270d39bfSRahul Lakkireddy t4_read_indirect(padap, 777270d39bfSRahul Lakkireddy sge_pio->ireg_addr, 778270d39bfSRahul Lakkireddy sge_pio->ireg_data, 779270d39bfSRahul Lakkireddy buff, 780270d39bfSRahul Lakkireddy sge_pio->ireg_offset_range, 781270d39bfSRahul Lakkireddy sge_pio->ireg_local_offset); 782270d39bfSRahul Lakkireddy ch_sge_dbg++; 783270d39bfSRahul Lakkireddy } 784270d39bfSRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 785270d39bfSRahul Lakkireddy return rc; 786270d39bfSRahul Lakkireddy } 787270d39bfSRahul Lakkireddy 78827887bc7SRahul Lakkireddy int cudbg_collect_ulprx_la(struct cudbg_init *pdbg_init, 78927887bc7SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 79027887bc7SRahul Lakkireddy struct cudbg_error *cudbg_err) 79127887bc7SRahul Lakkireddy { 79227887bc7SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 79327887bc7SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 79427887bc7SRahul Lakkireddy struct cudbg_ulprx_la *ulprx_la_buff; 79527887bc7SRahul Lakkireddy int rc; 79627887bc7SRahul Lakkireddy 79727887bc7SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, sizeof(struct cudbg_ulprx_la), 79827887bc7SRahul Lakkireddy &temp_buff); 79927887bc7SRahul Lakkireddy if (rc) 80027887bc7SRahul Lakkireddy return rc; 80127887bc7SRahul Lakkireddy 80227887bc7SRahul Lakkireddy ulprx_la_buff = (struct cudbg_ulprx_la *)temp_buff.data; 80327887bc7SRahul Lakkireddy t4_ulprx_read_la(padap, (u32 *)ulprx_la_buff->data); 80427887bc7SRahul Lakkireddy ulprx_la_buff->size = ULPRX_LA_SIZE; 80527887bc7SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 80627887bc7SRahul Lakkireddy return rc; 80727887bc7SRahul Lakkireddy } 80827887bc7SRahul Lakkireddy 80927887bc7SRahul Lakkireddy int cudbg_collect_tp_la(struct cudbg_init *pdbg_init, 81027887bc7SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 81127887bc7SRahul Lakkireddy struct cudbg_error *cudbg_err) 81227887bc7SRahul Lakkireddy { 81327887bc7SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 81427887bc7SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 81527887bc7SRahul Lakkireddy struct cudbg_tp_la *tp_la_buff; 81627887bc7SRahul Lakkireddy int size, rc; 81727887bc7SRahul Lakkireddy 81827887bc7SRahul Lakkireddy size = sizeof(struct cudbg_tp_la) + TPLA_SIZE * sizeof(u64); 81927887bc7SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, size, &temp_buff); 82027887bc7SRahul Lakkireddy if (rc) 82127887bc7SRahul Lakkireddy return rc; 82227887bc7SRahul Lakkireddy 82327887bc7SRahul Lakkireddy tp_la_buff = (struct cudbg_tp_la *)temp_buff.data; 82427887bc7SRahul Lakkireddy tp_la_buff->mode = DBGLAMODE_G(t4_read_reg(padap, TP_DBG_LA_CONFIG_A)); 82527887bc7SRahul Lakkireddy t4_tp_read_la(padap, (u64 *)tp_la_buff->data, NULL); 82627887bc7SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 82727887bc7SRahul Lakkireddy return rc; 82827887bc7SRahul Lakkireddy } 82927887bc7SRahul Lakkireddy 83027887bc7SRahul Lakkireddy int cudbg_collect_cim_pif_la(struct cudbg_init *pdbg_init, 83127887bc7SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 83227887bc7SRahul Lakkireddy struct cudbg_error *cudbg_err) 83327887bc7SRahul Lakkireddy { 83427887bc7SRahul Lakkireddy struct cudbg_cim_pif_la *cim_pif_la_buff; 83527887bc7SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 83627887bc7SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 83727887bc7SRahul Lakkireddy int size, rc; 83827887bc7SRahul Lakkireddy 83927887bc7SRahul Lakkireddy size = sizeof(struct cudbg_cim_pif_la) + 84027887bc7SRahul Lakkireddy 2 * CIM_PIFLA_SIZE * 6 * sizeof(u32); 84127887bc7SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, size, &temp_buff); 84227887bc7SRahul Lakkireddy if (rc) 84327887bc7SRahul Lakkireddy return rc; 84427887bc7SRahul Lakkireddy 84527887bc7SRahul Lakkireddy cim_pif_la_buff = (struct cudbg_cim_pif_la *)temp_buff.data; 84627887bc7SRahul Lakkireddy cim_pif_la_buff->size = CIM_PIFLA_SIZE; 84727887bc7SRahul Lakkireddy t4_cim_read_pif_la(padap, (u32 *)cim_pif_la_buff->data, 84827887bc7SRahul Lakkireddy (u32 *)cim_pif_la_buff->data + 6 * CIM_PIFLA_SIZE, 84927887bc7SRahul Lakkireddy NULL, NULL); 85027887bc7SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 85127887bc7SRahul Lakkireddy return rc; 85227887bc7SRahul Lakkireddy } 85327887bc7SRahul Lakkireddy 8546f92a654SRahul Lakkireddy int cudbg_collect_clk_info(struct cudbg_init *pdbg_init, 8556f92a654SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 8566f92a654SRahul Lakkireddy struct cudbg_error *cudbg_err) 8576f92a654SRahul Lakkireddy { 8586f92a654SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 8596f92a654SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 8606f92a654SRahul Lakkireddy struct cudbg_clk_info *clk_info_buff; 8616f92a654SRahul Lakkireddy u64 tp_tick_us; 8626f92a654SRahul Lakkireddy int rc; 8636f92a654SRahul Lakkireddy 8646f92a654SRahul Lakkireddy if (!padap->params.vpd.cclk) 8656f92a654SRahul Lakkireddy return CUDBG_STATUS_CCLK_NOT_DEFINED; 8666f92a654SRahul Lakkireddy 8676f92a654SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, sizeof(struct cudbg_clk_info), 8686f92a654SRahul Lakkireddy &temp_buff); 8696f92a654SRahul Lakkireddy if (rc) 8706f92a654SRahul Lakkireddy return rc; 8716f92a654SRahul Lakkireddy 8726f92a654SRahul Lakkireddy clk_info_buff = (struct cudbg_clk_info *)temp_buff.data; 8736f92a654SRahul Lakkireddy clk_info_buff->cclk_ps = 1000000000 / padap->params.vpd.cclk; /* psec */ 8746f92a654SRahul Lakkireddy clk_info_buff->res = t4_read_reg(padap, TP_TIMER_RESOLUTION_A); 8756f92a654SRahul Lakkireddy clk_info_buff->tre = TIMERRESOLUTION_G(clk_info_buff->res); 8766f92a654SRahul Lakkireddy clk_info_buff->dack_re = DELAYEDACKRESOLUTION_G(clk_info_buff->res); 8776f92a654SRahul Lakkireddy tp_tick_us = (clk_info_buff->cclk_ps << clk_info_buff->tre) / 1000000; 8786f92a654SRahul Lakkireddy 8796f92a654SRahul Lakkireddy clk_info_buff->dack_timer = 8806f92a654SRahul Lakkireddy (clk_info_buff->cclk_ps << clk_info_buff->dack_re) / 1000000 * 8816f92a654SRahul Lakkireddy t4_read_reg(padap, TP_DACK_TIMER_A); 8826f92a654SRahul Lakkireddy clk_info_buff->retransmit_min = 8836f92a654SRahul Lakkireddy tp_tick_us * t4_read_reg(padap, TP_RXT_MIN_A); 8846f92a654SRahul Lakkireddy clk_info_buff->retransmit_max = 8856f92a654SRahul Lakkireddy tp_tick_us * t4_read_reg(padap, TP_RXT_MAX_A); 8866f92a654SRahul Lakkireddy clk_info_buff->persist_timer_min = 8876f92a654SRahul Lakkireddy tp_tick_us * t4_read_reg(padap, TP_PERS_MIN_A); 8886f92a654SRahul Lakkireddy clk_info_buff->persist_timer_max = 8896f92a654SRahul Lakkireddy tp_tick_us * t4_read_reg(padap, TP_PERS_MAX_A); 8906f92a654SRahul Lakkireddy clk_info_buff->keepalive_idle_timer = 8916f92a654SRahul Lakkireddy tp_tick_us * t4_read_reg(padap, TP_KEEP_IDLE_A); 8926f92a654SRahul Lakkireddy clk_info_buff->keepalive_interval = 8936f92a654SRahul Lakkireddy tp_tick_us * t4_read_reg(padap, TP_KEEP_INTVL_A); 8946f92a654SRahul Lakkireddy clk_info_buff->initial_srtt = 8956f92a654SRahul Lakkireddy tp_tick_us * INITSRTT_G(t4_read_reg(padap, TP_INIT_SRTT_A)); 8966f92a654SRahul Lakkireddy clk_info_buff->finwait2_timer = 8976f92a654SRahul Lakkireddy tp_tick_us * t4_read_reg(padap, TP_FINWAIT2_TIMER_A); 8986f92a654SRahul Lakkireddy 8996f92a654SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 9006f92a654SRahul Lakkireddy return rc; 9016f92a654SRahul Lakkireddy } 9026f92a654SRahul Lakkireddy 903270d39bfSRahul Lakkireddy int cudbg_collect_pcie_indirect(struct cudbg_init *pdbg_init, 904270d39bfSRahul Lakkireddy struct cudbg_buffer *dbg_buff, 905270d39bfSRahul Lakkireddy struct cudbg_error *cudbg_err) 906270d39bfSRahul Lakkireddy { 907270d39bfSRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 908270d39bfSRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 909270d39bfSRahul Lakkireddy struct ireg_buf *ch_pcie; 910270d39bfSRahul Lakkireddy int i, rc, n; 911270d39bfSRahul Lakkireddy u32 size; 912270d39bfSRahul Lakkireddy 913270d39bfSRahul Lakkireddy n = sizeof(t5_pcie_pdbg_array) / (IREG_NUM_ELEM * sizeof(u32)); 914270d39bfSRahul Lakkireddy size = sizeof(struct ireg_buf) * n * 2; 915270d39bfSRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, size, &temp_buff); 916270d39bfSRahul Lakkireddy if (rc) 917270d39bfSRahul Lakkireddy return rc; 918270d39bfSRahul Lakkireddy 919270d39bfSRahul Lakkireddy ch_pcie = (struct ireg_buf *)temp_buff.data; 920270d39bfSRahul Lakkireddy /* PCIE_PDBG */ 921270d39bfSRahul Lakkireddy for (i = 0; i < n; i++) { 922270d39bfSRahul Lakkireddy struct ireg_field *pcie_pio = &ch_pcie->tp_pio; 923270d39bfSRahul Lakkireddy u32 *buff = ch_pcie->outbuf; 924270d39bfSRahul Lakkireddy 925270d39bfSRahul Lakkireddy pcie_pio->ireg_addr = t5_pcie_pdbg_array[i][0]; 926270d39bfSRahul Lakkireddy pcie_pio->ireg_data = t5_pcie_pdbg_array[i][1]; 927270d39bfSRahul Lakkireddy pcie_pio->ireg_local_offset = t5_pcie_pdbg_array[i][2]; 928270d39bfSRahul Lakkireddy pcie_pio->ireg_offset_range = t5_pcie_pdbg_array[i][3]; 929270d39bfSRahul Lakkireddy t4_read_indirect(padap, 930270d39bfSRahul Lakkireddy pcie_pio->ireg_addr, 931270d39bfSRahul Lakkireddy pcie_pio->ireg_data, 932270d39bfSRahul Lakkireddy buff, 933270d39bfSRahul Lakkireddy pcie_pio->ireg_offset_range, 934270d39bfSRahul Lakkireddy pcie_pio->ireg_local_offset); 935270d39bfSRahul Lakkireddy ch_pcie++; 936270d39bfSRahul Lakkireddy } 937270d39bfSRahul Lakkireddy 938270d39bfSRahul Lakkireddy /* PCIE_CDBG */ 939270d39bfSRahul Lakkireddy n = sizeof(t5_pcie_cdbg_array) / (IREG_NUM_ELEM * sizeof(u32)); 940270d39bfSRahul Lakkireddy for (i = 0; i < n; i++) { 941270d39bfSRahul Lakkireddy struct ireg_field *pcie_pio = &ch_pcie->tp_pio; 942270d39bfSRahul Lakkireddy u32 *buff = ch_pcie->outbuf; 943270d39bfSRahul Lakkireddy 944270d39bfSRahul Lakkireddy pcie_pio->ireg_addr = t5_pcie_cdbg_array[i][0]; 945270d39bfSRahul Lakkireddy pcie_pio->ireg_data = t5_pcie_cdbg_array[i][1]; 946270d39bfSRahul Lakkireddy pcie_pio->ireg_local_offset = t5_pcie_cdbg_array[i][2]; 947270d39bfSRahul Lakkireddy pcie_pio->ireg_offset_range = t5_pcie_cdbg_array[i][3]; 948270d39bfSRahul Lakkireddy t4_read_indirect(padap, 949270d39bfSRahul Lakkireddy pcie_pio->ireg_addr, 950270d39bfSRahul Lakkireddy pcie_pio->ireg_data, 951270d39bfSRahul Lakkireddy buff, 952270d39bfSRahul Lakkireddy pcie_pio->ireg_offset_range, 953270d39bfSRahul Lakkireddy pcie_pio->ireg_local_offset); 954270d39bfSRahul Lakkireddy ch_pcie++; 955270d39bfSRahul Lakkireddy } 956270d39bfSRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 957270d39bfSRahul Lakkireddy return rc; 958270d39bfSRahul Lakkireddy } 959270d39bfSRahul Lakkireddy 960270d39bfSRahul Lakkireddy int cudbg_collect_pm_indirect(struct cudbg_init *pdbg_init, 961270d39bfSRahul Lakkireddy struct cudbg_buffer *dbg_buff, 962270d39bfSRahul Lakkireddy struct cudbg_error *cudbg_err) 963270d39bfSRahul Lakkireddy { 964270d39bfSRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 965270d39bfSRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 966270d39bfSRahul Lakkireddy struct ireg_buf *ch_pm; 967270d39bfSRahul Lakkireddy int i, rc, n; 968270d39bfSRahul Lakkireddy u32 size; 969270d39bfSRahul Lakkireddy 970270d39bfSRahul Lakkireddy n = sizeof(t5_pm_rx_array) / (IREG_NUM_ELEM * sizeof(u32)); 971270d39bfSRahul Lakkireddy size = sizeof(struct ireg_buf) * n * 2; 972270d39bfSRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, size, &temp_buff); 973270d39bfSRahul Lakkireddy if (rc) 974270d39bfSRahul Lakkireddy return rc; 975270d39bfSRahul Lakkireddy 976270d39bfSRahul Lakkireddy ch_pm = (struct ireg_buf *)temp_buff.data; 977270d39bfSRahul Lakkireddy /* PM_RX */ 978270d39bfSRahul Lakkireddy for (i = 0; i < n; i++) { 979270d39bfSRahul Lakkireddy struct ireg_field *pm_pio = &ch_pm->tp_pio; 980270d39bfSRahul Lakkireddy u32 *buff = ch_pm->outbuf; 981270d39bfSRahul Lakkireddy 982270d39bfSRahul Lakkireddy pm_pio->ireg_addr = t5_pm_rx_array[i][0]; 983270d39bfSRahul Lakkireddy pm_pio->ireg_data = t5_pm_rx_array[i][1]; 984270d39bfSRahul Lakkireddy pm_pio->ireg_local_offset = t5_pm_rx_array[i][2]; 985270d39bfSRahul Lakkireddy pm_pio->ireg_offset_range = t5_pm_rx_array[i][3]; 986270d39bfSRahul Lakkireddy t4_read_indirect(padap, 987270d39bfSRahul Lakkireddy pm_pio->ireg_addr, 988270d39bfSRahul Lakkireddy pm_pio->ireg_data, 989270d39bfSRahul Lakkireddy buff, 990270d39bfSRahul Lakkireddy pm_pio->ireg_offset_range, 991270d39bfSRahul Lakkireddy pm_pio->ireg_local_offset); 992270d39bfSRahul Lakkireddy ch_pm++; 993270d39bfSRahul Lakkireddy } 994270d39bfSRahul Lakkireddy 995270d39bfSRahul Lakkireddy /* PM_TX */ 996270d39bfSRahul Lakkireddy n = sizeof(t5_pm_tx_array) / (IREG_NUM_ELEM * sizeof(u32)); 997270d39bfSRahul Lakkireddy for (i = 0; i < n; i++) { 998270d39bfSRahul Lakkireddy struct ireg_field *pm_pio = &ch_pm->tp_pio; 999270d39bfSRahul Lakkireddy u32 *buff = ch_pm->outbuf; 1000270d39bfSRahul Lakkireddy 1001270d39bfSRahul Lakkireddy pm_pio->ireg_addr = t5_pm_tx_array[i][0]; 1002270d39bfSRahul Lakkireddy pm_pio->ireg_data = t5_pm_tx_array[i][1]; 1003270d39bfSRahul Lakkireddy pm_pio->ireg_local_offset = t5_pm_tx_array[i][2]; 1004270d39bfSRahul Lakkireddy pm_pio->ireg_offset_range = t5_pm_tx_array[i][3]; 1005270d39bfSRahul Lakkireddy t4_read_indirect(padap, 1006270d39bfSRahul Lakkireddy pm_pio->ireg_addr, 1007270d39bfSRahul Lakkireddy pm_pio->ireg_data, 1008270d39bfSRahul Lakkireddy buff, 1009270d39bfSRahul Lakkireddy pm_pio->ireg_offset_range, 1010270d39bfSRahul Lakkireddy pm_pio->ireg_local_offset); 1011270d39bfSRahul Lakkireddy ch_pm++; 1012270d39bfSRahul Lakkireddy } 1013270d39bfSRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 1014270d39bfSRahul Lakkireddy return rc; 1015270d39bfSRahul Lakkireddy } 1016270d39bfSRahul Lakkireddy 10179030e498SRahul Lakkireddy int cudbg_collect_tid(struct cudbg_init *pdbg_init, 10189030e498SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 10199030e498SRahul Lakkireddy struct cudbg_error *cudbg_err) 10209030e498SRahul Lakkireddy { 10219030e498SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 10229030e498SRahul Lakkireddy struct cudbg_tid_info_region_rev1 *tid1; 10239030e498SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 10249030e498SRahul Lakkireddy struct cudbg_tid_info_region *tid; 10259030e498SRahul Lakkireddy u32 para[2], val[2]; 10269030e498SRahul Lakkireddy int rc; 10279030e498SRahul Lakkireddy 10289030e498SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, sizeof(struct cudbg_tid_info_region_rev1), 10299030e498SRahul Lakkireddy &temp_buff); 10309030e498SRahul Lakkireddy if (rc) 10319030e498SRahul Lakkireddy return rc; 10329030e498SRahul Lakkireddy 10339030e498SRahul Lakkireddy tid1 = (struct cudbg_tid_info_region_rev1 *)temp_buff.data; 10349030e498SRahul Lakkireddy tid = &tid1->tid; 10359030e498SRahul Lakkireddy tid1->ver_hdr.signature = CUDBG_ENTITY_SIGNATURE; 10369030e498SRahul Lakkireddy tid1->ver_hdr.revision = CUDBG_TID_INFO_REV; 10379030e498SRahul Lakkireddy tid1->ver_hdr.size = sizeof(struct cudbg_tid_info_region_rev1) - 10389030e498SRahul Lakkireddy sizeof(struct cudbg_ver_hdr); 10399030e498SRahul Lakkireddy 10409030e498SRahul Lakkireddy #define FW_PARAM_PFVF_A(param) \ 10419030e498SRahul Lakkireddy (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_PFVF) | \ 10429030e498SRahul Lakkireddy FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_PFVF_##param) | \ 10439030e498SRahul Lakkireddy FW_PARAMS_PARAM_Y_V(0) | \ 10449030e498SRahul Lakkireddy FW_PARAMS_PARAM_Z_V(0)) 10459030e498SRahul Lakkireddy 10469030e498SRahul Lakkireddy para[0] = FW_PARAM_PFVF_A(ETHOFLD_START); 10479030e498SRahul Lakkireddy para[1] = FW_PARAM_PFVF_A(ETHOFLD_END); 10489030e498SRahul Lakkireddy rc = t4_query_params(padap, padap->mbox, padap->pf, 0, 2, para, val); 10499030e498SRahul Lakkireddy if (rc < 0) { 10509030e498SRahul Lakkireddy cudbg_err->sys_err = rc; 10519030e498SRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 10529030e498SRahul Lakkireddy return rc; 10539030e498SRahul Lakkireddy } 10549030e498SRahul Lakkireddy tid->uotid_base = val[0]; 10559030e498SRahul Lakkireddy tid->nuotids = val[1] - val[0] + 1; 10569030e498SRahul Lakkireddy 10579030e498SRahul Lakkireddy if (is_t5(padap->params.chip)) { 10589030e498SRahul Lakkireddy tid->sb = t4_read_reg(padap, LE_DB_SERVER_INDEX_A) / 4; 10599030e498SRahul Lakkireddy } else if (is_t6(padap->params.chip)) { 10609030e498SRahul Lakkireddy tid1->tid_start = 10619030e498SRahul Lakkireddy t4_read_reg(padap, LE_DB_ACTIVE_TABLE_START_INDEX_A); 10629030e498SRahul Lakkireddy tid->sb = t4_read_reg(padap, LE_DB_SRVR_START_INDEX_A); 10639030e498SRahul Lakkireddy 10649030e498SRahul Lakkireddy para[0] = FW_PARAM_PFVF_A(HPFILTER_START); 10659030e498SRahul Lakkireddy para[1] = FW_PARAM_PFVF_A(HPFILTER_END); 10669030e498SRahul Lakkireddy rc = t4_query_params(padap, padap->mbox, padap->pf, 0, 2, 10679030e498SRahul Lakkireddy para, val); 10689030e498SRahul Lakkireddy if (rc < 0) { 10699030e498SRahul Lakkireddy cudbg_err->sys_err = rc; 10709030e498SRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 10719030e498SRahul Lakkireddy return rc; 10729030e498SRahul Lakkireddy } 10739030e498SRahul Lakkireddy tid->hpftid_base = val[0]; 10749030e498SRahul Lakkireddy tid->nhpftids = val[1] - val[0] + 1; 10759030e498SRahul Lakkireddy } 10769030e498SRahul Lakkireddy 10779030e498SRahul Lakkireddy tid->ntids = padap->tids.ntids; 10789030e498SRahul Lakkireddy tid->nstids = padap->tids.nstids; 10799030e498SRahul Lakkireddy tid->stid_base = padap->tids.stid_base; 10809030e498SRahul Lakkireddy tid->hash_base = padap->tids.hash_base; 10819030e498SRahul Lakkireddy 10829030e498SRahul Lakkireddy tid->natids = padap->tids.natids; 10839030e498SRahul Lakkireddy tid->nftids = padap->tids.nftids; 10849030e498SRahul Lakkireddy tid->ftid_base = padap->tids.ftid_base; 10859030e498SRahul Lakkireddy tid->aftid_base = padap->tids.aftid_base; 10869030e498SRahul Lakkireddy tid->aftid_end = padap->tids.aftid_end; 10879030e498SRahul Lakkireddy 10889030e498SRahul Lakkireddy tid->sftid_base = padap->tids.sftid_base; 10899030e498SRahul Lakkireddy tid->nsftids = padap->tids.nsftids; 10909030e498SRahul Lakkireddy 10919030e498SRahul Lakkireddy tid->flags = padap->flags; 10929030e498SRahul Lakkireddy tid->le_db_conf = t4_read_reg(padap, LE_DB_CONFIG_A); 10939030e498SRahul Lakkireddy tid->ip_users = t4_read_reg(padap, LE_DB_ACT_CNT_IPV4_A); 10949030e498SRahul Lakkireddy tid->ipv6_users = t4_read_reg(padap, LE_DB_ACT_CNT_IPV6_A); 10959030e498SRahul Lakkireddy 10969030e498SRahul Lakkireddy #undef FW_PARAM_PFVF_A 10979030e498SRahul Lakkireddy 10989030e498SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 10999030e498SRahul Lakkireddy return rc; 11009030e498SRahul Lakkireddy } 11019030e498SRahul Lakkireddy 1102b289593eSRahul Lakkireddy static inline void cudbg_tcamxy2valmask(u64 x, u64 y, u8 *addr, u64 *mask) 1103b289593eSRahul Lakkireddy { 1104b289593eSRahul Lakkireddy *mask = x | y; 1105b289593eSRahul Lakkireddy y = (__force u64)cpu_to_be64(y); 1106b289593eSRahul Lakkireddy memcpy(addr, (char *)&y + 2, ETH_ALEN); 1107b289593eSRahul Lakkireddy } 1108b289593eSRahul Lakkireddy 1109b289593eSRahul Lakkireddy static void cudbg_mps_rpl_backdoor(struct adapter *padap, 1110b289593eSRahul Lakkireddy struct fw_ldst_mps_rplc *mps_rplc) 1111b289593eSRahul Lakkireddy { 1112b289593eSRahul Lakkireddy if (is_t5(padap->params.chip)) { 1113b289593eSRahul Lakkireddy mps_rplc->rplc255_224 = htonl(t4_read_reg(padap, 1114b289593eSRahul Lakkireddy MPS_VF_RPLCT_MAP3_A)); 1115b289593eSRahul Lakkireddy mps_rplc->rplc223_192 = htonl(t4_read_reg(padap, 1116b289593eSRahul Lakkireddy MPS_VF_RPLCT_MAP2_A)); 1117b289593eSRahul Lakkireddy mps_rplc->rplc191_160 = htonl(t4_read_reg(padap, 1118b289593eSRahul Lakkireddy MPS_VF_RPLCT_MAP1_A)); 1119b289593eSRahul Lakkireddy mps_rplc->rplc159_128 = htonl(t4_read_reg(padap, 1120b289593eSRahul Lakkireddy MPS_VF_RPLCT_MAP0_A)); 1121b289593eSRahul Lakkireddy } else { 1122b289593eSRahul Lakkireddy mps_rplc->rplc255_224 = htonl(t4_read_reg(padap, 1123b289593eSRahul Lakkireddy MPS_VF_RPLCT_MAP7_A)); 1124b289593eSRahul Lakkireddy mps_rplc->rplc223_192 = htonl(t4_read_reg(padap, 1125b289593eSRahul Lakkireddy MPS_VF_RPLCT_MAP6_A)); 1126b289593eSRahul Lakkireddy mps_rplc->rplc191_160 = htonl(t4_read_reg(padap, 1127b289593eSRahul Lakkireddy MPS_VF_RPLCT_MAP5_A)); 1128b289593eSRahul Lakkireddy mps_rplc->rplc159_128 = htonl(t4_read_reg(padap, 1129b289593eSRahul Lakkireddy MPS_VF_RPLCT_MAP4_A)); 1130b289593eSRahul Lakkireddy } 1131b289593eSRahul Lakkireddy mps_rplc->rplc127_96 = htonl(t4_read_reg(padap, MPS_VF_RPLCT_MAP3_A)); 1132b289593eSRahul Lakkireddy mps_rplc->rplc95_64 = htonl(t4_read_reg(padap, MPS_VF_RPLCT_MAP2_A)); 1133b289593eSRahul Lakkireddy mps_rplc->rplc63_32 = htonl(t4_read_reg(padap, MPS_VF_RPLCT_MAP1_A)); 1134b289593eSRahul Lakkireddy mps_rplc->rplc31_0 = htonl(t4_read_reg(padap, MPS_VF_RPLCT_MAP0_A)); 1135b289593eSRahul Lakkireddy } 1136b289593eSRahul Lakkireddy 1137b289593eSRahul Lakkireddy static int cudbg_collect_tcam_index(struct adapter *padap, 1138b289593eSRahul Lakkireddy struct cudbg_mps_tcam *tcam, u32 idx) 1139b289593eSRahul Lakkireddy { 1140b289593eSRahul Lakkireddy u64 tcamy, tcamx, val; 1141b289593eSRahul Lakkireddy u32 ctl, data2; 1142b289593eSRahul Lakkireddy int rc = 0; 1143b289593eSRahul Lakkireddy 1144b289593eSRahul Lakkireddy if (CHELSIO_CHIP_VERSION(padap->params.chip) >= CHELSIO_T6) { 1145b289593eSRahul Lakkireddy /* CtlReqID - 1: use Host Driver Requester ID 1146b289593eSRahul Lakkireddy * CtlCmdType - 0: Read, 1: Write 1147b289593eSRahul Lakkireddy * CtlTcamSel - 0: TCAM0, 1: TCAM1 1148b289593eSRahul Lakkireddy * CtlXYBitSel- 0: Y bit, 1: X bit 1149b289593eSRahul Lakkireddy */ 1150b289593eSRahul Lakkireddy 1151b289593eSRahul Lakkireddy /* Read tcamy */ 1152b289593eSRahul Lakkireddy ctl = CTLREQID_V(1) | CTLCMDTYPE_V(0) | CTLXYBITSEL_V(0); 1153b289593eSRahul Lakkireddy if (idx < 256) 1154b289593eSRahul Lakkireddy ctl |= CTLTCAMINDEX_V(idx) | CTLTCAMSEL_V(0); 1155b289593eSRahul Lakkireddy else 1156b289593eSRahul Lakkireddy ctl |= CTLTCAMINDEX_V(idx - 256) | CTLTCAMSEL_V(1); 1157b289593eSRahul Lakkireddy 1158b289593eSRahul Lakkireddy t4_write_reg(padap, MPS_CLS_TCAM_DATA2_CTL_A, ctl); 1159b289593eSRahul Lakkireddy val = t4_read_reg(padap, MPS_CLS_TCAM_RDATA1_REQ_ID1_A); 1160b289593eSRahul Lakkireddy tcamy = DMACH_G(val) << 32; 1161b289593eSRahul Lakkireddy tcamy |= t4_read_reg(padap, MPS_CLS_TCAM_RDATA0_REQ_ID1_A); 1162b289593eSRahul Lakkireddy data2 = t4_read_reg(padap, MPS_CLS_TCAM_RDATA2_REQ_ID1_A); 1163b289593eSRahul Lakkireddy tcam->lookup_type = DATALKPTYPE_G(data2); 1164b289593eSRahul Lakkireddy 1165b289593eSRahul Lakkireddy /* 0 - Outer header, 1 - Inner header 1166b289593eSRahul Lakkireddy * [71:48] bit locations are overloaded for 1167b289593eSRahul Lakkireddy * outer vs. inner lookup types. 1168b289593eSRahul Lakkireddy */ 1169b289593eSRahul Lakkireddy if (tcam->lookup_type && tcam->lookup_type != DATALKPTYPE_M) { 1170b289593eSRahul Lakkireddy /* Inner header VNI */ 1171b289593eSRahul Lakkireddy tcam->vniy = (data2 & DATAVIDH2_F) | DATAVIDH1_G(data2); 1172b289593eSRahul Lakkireddy tcam->vniy = (tcam->vniy << 16) | VIDL_G(val); 1173b289593eSRahul Lakkireddy tcam->dip_hit = data2 & DATADIPHIT_F; 1174b289593eSRahul Lakkireddy } else { 1175b289593eSRahul Lakkireddy tcam->vlan_vld = data2 & DATAVIDH2_F; 1176b289593eSRahul Lakkireddy tcam->ivlan = VIDL_G(val); 1177b289593eSRahul Lakkireddy } 1178b289593eSRahul Lakkireddy 1179b289593eSRahul Lakkireddy tcam->port_num = DATAPORTNUM_G(data2); 1180b289593eSRahul Lakkireddy 1181b289593eSRahul Lakkireddy /* Read tcamx. Change the control param */ 1182b289593eSRahul Lakkireddy ctl |= CTLXYBITSEL_V(1); 1183b289593eSRahul Lakkireddy t4_write_reg(padap, MPS_CLS_TCAM_DATA2_CTL_A, ctl); 1184b289593eSRahul Lakkireddy val = t4_read_reg(padap, MPS_CLS_TCAM_RDATA1_REQ_ID1_A); 1185b289593eSRahul Lakkireddy tcamx = DMACH_G(val) << 32; 1186b289593eSRahul Lakkireddy tcamx |= t4_read_reg(padap, MPS_CLS_TCAM_RDATA0_REQ_ID1_A); 1187b289593eSRahul Lakkireddy data2 = t4_read_reg(padap, MPS_CLS_TCAM_RDATA2_REQ_ID1_A); 1188b289593eSRahul Lakkireddy if (tcam->lookup_type && tcam->lookup_type != DATALKPTYPE_M) { 1189b289593eSRahul Lakkireddy /* Inner header VNI mask */ 1190b289593eSRahul Lakkireddy tcam->vnix = (data2 & DATAVIDH2_F) | DATAVIDH1_G(data2); 1191b289593eSRahul Lakkireddy tcam->vnix = (tcam->vnix << 16) | VIDL_G(val); 1192b289593eSRahul Lakkireddy } 1193b289593eSRahul Lakkireddy } else { 1194b289593eSRahul Lakkireddy tcamy = t4_read_reg64(padap, MPS_CLS_TCAM_Y_L(idx)); 1195b289593eSRahul Lakkireddy tcamx = t4_read_reg64(padap, MPS_CLS_TCAM_X_L(idx)); 1196b289593eSRahul Lakkireddy } 1197b289593eSRahul Lakkireddy 1198b289593eSRahul Lakkireddy /* If no entry, return */ 1199b289593eSRahul Lakkireddy if (tcamx & tcamy) 1200b289593eSRahul Lakkireddy return rc; 1201b289593eSRahul Lakkireddy 1202b289593eSRahul Lakkireddy tcam->cls_lo = t4_read_reg(padap, MPS_CLS_SRAM_L(idx)); 1203b289593eSRahul Lakkireddy tcam->cls_hi = t4_read_reg(padap, MPS_CLS_SRAM_H(idx)); 1204b289593eSRahul Lakkireddy 1205b289593eSRahul Lakkireddy if (is_t5(padap->params.chip)) 1206b289593eSRahul Lakkireddy tcam->repli = (tcam->cls_lo & REPLICATE_F); 1207b289593eSRahul Lakkireddy else if (is_t6(padap->params.chip)) 1208b289593eSRahul Lakkireddy tcam->repli = (tcam->cls_lo & T6_REPLICATE_F); 1209b289593eSRahul Lakkireddy 1210b289593eSRahul Lakkireddy if (tcam->repli) { 1211b289593eSRahul Lakkireddy struct fw_ldst_cmd ldst_cmd; 1212b289593eSRahul Lakkireddy struct fw_ldst_mps_rplc mps_rplc; 1213b289593eSRahul Lakkireddy 1214b289593eSRahul Lakkireddy memset(&ldst_cmd, 0, sizeof(ldst_cmd)); 1215b289593eSRahul Lakkireddy ldst_cmd.op_to_addrspace = 1216b289593eSRahul Lakkireddy htonl(FW_CMD_OP_V(FW_LDST_CMD) | 1217b289593eSRahul Lakkireddy FW_CMD_REQUEST_F | FW_CMD_READ_F | 1218b289593eSRahul Lakkireddy FW_LDST_CMD_ADDRSPACE_V(FW_LDST_ADDRSPC_MPS)); 1219b289593eSRahul Lakkireddy ldst_cmd.cycles_to_len16 = htonl(FW_LEN16(ldst_cmd)); 1220b289593eSRahul Lakkireddy ldst_cmd.u.mps.rplc.fid_idx = 1221b289593eSRahul Lakkireddy htons(FW_LDST_CMD_FID_V(FW_LDST_MPS_RPLC) | 1222b289593eSRahul Lakkireddy FW_LDST_CMD_IDX_V(idx)); 1223b289593eSRahul Lakkireddy 1224b289593eSRahul Lakkireddy rc = t4_wr_mbox(padap, padap->mbox, &ldst_cmd, sizeof(ldst_cmd), 1225b289593eSRahul Lakkireddy &ldst_cmd); 1226b289593eSRahul Lakkireddy if (rc) 1227b289593eSRahul Lakkireddy cudbg_mps_rpl_backdoor(padap, &mps_rplc); 1228b289593eSRahul Lakkireddy else 1229b289593eSRahul Lakkireddy mps_rplc = ldst_cmd.u.mps.rplc; 1230b289593eSRahul Lakkireddy 1231b289593eSRahul Lakkireddy tcam->rplc[0] = ntohl(mps_rplc.rplc31_0); 1232b289593eSRahul Lakkireddy tcam->rplc[1] = ntohl(mps_rplc.rplc63_32); 1233b289593eSRahul Lakkireddy tcam->rplc[2] = ntohl(mps_rplc.rplc95_64); 1234b289593eSRahul Lakkireddy tcam->rplc[3] = ntohl(mps_rplc.rplc127_96); 1235b289593eSRahul Lakkireddy if (padap->params.arch.mps_rplc_size > CUDBG_MAX_RPLC_SIZE) { 1236b289593eSRahul Lakkireddy tcam->rplc[4] = ntohl(mps_rplc.rplc159_128); 1237b289593eSRahul Lakkireddy tcam->rplc[5] = ntohl(mps_rplc.rplc191_160); 1238b289593eSRahul Lakkireddy tcam->rplc[6] = ntohl(mps_rplc.rplc223_192); 1239b289593eSRahul Lakkireddy tcam->rplc[7] = ntohl(mps_rplc.rplc255_224); 1240b289593eSRahul Lakkireddy } 1241b289593eSRahul Lakkireddy } 1242b289593eSRahul Lakkireddy cudbg_tcamxy2valmask(tcamx, tcamy, tcam->addr, &tcam->mask); 1243b289593eSRahul Lakkireddy tcam->idx = idx; 1244b289593eSRahul Lakkireddy tcam->rplc_size = padap->params.arch.mps_rplc_size; 1245b289593eSRahul Lakkireddy return rc; 1246b289593eSRahul Lakkireddy } 1247b289593eSRahul Lakkireddy 1248b289593eSRahul Lakkireddy int cudbg_collect_mps_tcam(struct cudbg_init *pdbg_init, 1249b289593eSRahul Lakkireddy struct cudbg_buffer *dbg_buff, 1250b289593eSRahul Lakkireddy struct cudbg_error *cudbg_err) 1251b289593eSRahul Lakkireddy { 1252b289593eSRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 1253b289593eSRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 1254b289593eSRahul Lakkireddy u32 size = 0, i, n, total_size = 0; 1255b289593eSRahul Lakkireddy struct cudbg_mps_tcam *tcam; 1256b289593eSRahul Lakkireddy int rc; 1257b289593eSRahul Lakkireddy 1258b289593eSRahul Lakkireddy n = padap->params.arch.mps_tcam_size; 1259b289593eSRahul Lakkireddy size = sizeof(struct cudbg_mps_tcam) * n; 1260b289593eSRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, size, &temp_buff); 1261b289593eSRahul Lakkireddy if (rc) 1262b289593eSRahul Lakkireddy return rc; 1263b289593eSRahul Lakkireddy 1264b289593eSRahul Lakkireddy tcam = (struct cudbg_mps_tcam *)temp_buff.data; 1265b289593eSRahul Lakkireddy for (i = 0; i < n; i++) { 1266b289593eSRahul Lakkireddy rc = cudbg_collect_tcam_index(padap, tcam, i); 1267b289593eSRahul Lakkireddy if (rc) { 1268b289593eSRahul Lakkireddy cudbg_err->sys_err = rc; 1269b289593eSRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 1270b289593eSRahul Lakkireddy return rc; 1271b289593eSRahul Lakkireddy } 1272b289593eSRahul Lakkireddy total_size += sizeof(struct cudbg_mps_tcam); 1273b289593eSRahul Lakkireddy tcam++; 1274b289593eSRahul Lakkireddy } 1275b289593eSRahul Lakkireddy 1276b289593eSRahul Lakkireddy if (!total_size) { 1277b289593eSRahul Lakkireddy rc = CUDBG_SYSTEM_ERROR; 1278b289593eSRahul Lakkireddy cudbg_err->sys_err = rc; 1279b289593eSRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 1280b289593eSRahul Lakkireddy return rc; 1281b289593eSRahul Lakkireddy } 1282b289593eSRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 1283b289593eSRahul Lakkireddy return rc; 1284b289593eSRahul Lakkireddy } 1285b289593eSRahul Lakkireddy 12866f92a654SRahul Lakkireddy int cudbg_collect_vpd_data(struct cudbg_init *pdbg_init, 12876f92a654SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 12886f92a654SRahul Lakkireddy struct cudbg_error *cudbg_err) 12896f92a654SRahul Lakkireddy { 12906f92a654SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 12916f92a654SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 12926f92a654SRahul Lakkireddy struct cudbg_vpd_data *vpd_data; 12936f92a654SRahul Lakkireddy int rc; 12946f92a654SRahul Lakkireddy 12956f92a654SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, sizeof(struct cudbg_vpd_data), 12966f92a654SRahul Lakkireddy &temp_buff); 12976f92a654SRahul Lakkireddy if (rc) 12986f92a654SRahul Lakkireddy return rc; 12996f92a654SRahul Lakkireddy 13006f92a654SRahul Lakkireddy vpd_data = (struct cudbg_vpd_data *)temp_buff.data; 13016f92a654SRahul Lakkireddy memcpy(vpd_data->sn, padap->params.vpd.sn, SERNUM_LEN + 1); 13026f92a654SRahul Lakkireddy memcpy(vpd_data->bn, padap->params.vpd.pn, PN_LEN + 1); 13036f92a654SRahul Lakkireddy memcpy(vpd_data->na, padap->params.vpd.na, MACADDR_LEN + 1); 13046f92a654SRahul Lakkireddy memcpy(vpd_data->mn, padap->params.vpd.id, ID_LEN + 1); 13056f92a654SRahul Lakkireddy vpd_data->scfg_vers = padap->params.scfg_vers; 13066f92a654SRahul Lakkireddy vpd_data->vpd_vers = padap->params.vpd_vers; 13076f92a654SRahul Lakkireddy vpd_data->fw_major = FW_HDR_FW_VER_MAJOR_G(padap->params.fw_vers); 13086f92a654SRahul Lakkireddy vpd_data->fw_minor = FW_HDR_FW_VER_MINOR_G(padap->params.fw_vers); 13096f92a654SRahul Lakkireddy vpd_data->fw_micro = FW_HDR_FW_VER_MICRO_G(padap->params.fw_vers); 13106f92a654SRahul Lakkireddy vpd_data->fw_build = FW_HDR_FW_VER_BUILD_G(padap->params.fw_vers); 13116f92a654SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 13126f92a654SRahul Lakkireddy return rc; 13136f92a654SRahul Lakkireddy } 13146f92a654SRahul Lakkireddy 13156f92a654SRahul Lakkireddy int cudbg_collect_cctrl(struct cudbg_init *pdbg_init, 13166f92a654SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 13176f92a654SRahul Lakkireddy struct cudbg_error *cudbg_err) 13186f92a654SRahul Lakkireddy { 13196f92a654SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 13206f92a654SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 13216f92a654SRahul Lakkireddy u32 size; 13226f92a654SRahul Lakkireddy int rc; 13236f92a654SRahul Lakkireddy 13246f92a654SRahul Lakkireddy size = sizeof(u16) * NMTUS * NCCTRL_WIN; 13256f92a654SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, size, &temp_buff); 13266f92a654SRahul Lakkireddy if (rc) 13276f92a654SRahul Lakkireddy return rc; 13286f92a654SRahul Lakkireddy 13296f92a654SRahul Lakkireddy t4_read_cong_tbl(padap, (void *)temp_buff.data); 13306f92a654SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 13316f92a654SRahul Lakkireddy return rc; 13326f92a654SRahul Lakkireddy } 13336f92a654SRahul Lakkireddy 1334270d39bfSRahul Lakkireddy int cudbg_collect_ma_indirect(struct cudbg_init *pdbg_init, 1335270d39bfSRahul Lakkireddy struct cudbg_buffer *dbg_buff, 1336270d39bfSRahul Lakkireddy struct cudbg_error *cudbg_err) 1337270d39bfSRahul Lakkireddy { 1338270d39bfSRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 1339270d39bfSRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 1340270d39bfSRahul Lakkireddy struct ireg_buf *ma_indr; 1341270d39bfSRahul Lakkireddy int i, rc, n; 1342270d39bfSRahul Lakkireddy u32 size, j; 1343270d39bfSRahul Lakkireddy 1344270d39bfSRahul Lakkireddy if (CHELSIO_CHIP_VERSION(padap->params.chip) < CHELSIO_T6) 1345270d39bfSRahul Lakkireddy return CUDBG_STATUS_ENTITY_NOT_FOUND; 1346270d39bfSRahul Lakkireddy 1347270d39bfSRahul Lakkireddy n = sizeof(t6_ma_ireg_array) / (IREG_NUM_ELEM * sizeof(u32)); 1348270d39bfSRahul Lakkireddy size = sizeof(struct ireg_buf) * n * 2; 1349270d39bfSRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, size, &temp_buff); 1350270d39bfSRahul Lakkireddy if (rc) 1351270d39bfSRahul Lakkireddy return rc; 1352270d39bfSRahul Lakkireddy 1353270d39bfSRahul Lakkireddy ma_indr = (struct ireg_buf *)temp_buff.data; 1354270d39bfSRahul Lakkireddy for (i = 0; i < n; i++) { 1355270d39bfSRahul Lakkireddy struct ireg_field *ma_fli = &ma_indr->tp_pio; 1356270d39bfSRahul Lakkireddy u32 *buff = ma_indr->outbuf; 1357270d39bfSRahul Lakkireddy 1358270d39bfSRahul Lakkireddy ma_fli->ireg_addr = t6_ma_ireg_array[i][0]; 1359270d39bfSRahul Lakkireddy ma_fli->ireg_data = t6_ma_ireg_array[i][1]; 1360270d39bfSRahul Lakkireddy ma_fli->ireg_local_offset = t6_ma_ireg_array[i][2]; 1361270d39bfSRahul Lakkireddy ma_fli->ireg_offset_range = t6_ma_ireg_array[i][3]; 1362270d39bfSRahul Lakkireddy t4_read_indirect(padap, ma_fli->ireg_addr, ma_fli->ireg_data, 1363270d39bfSRahul Lakkireddy buff, ma_fli->ireg_offset_range, 1364270d39bfSRahul Lakkireddy ma_fli->ireg_local_offset); 1365270d39bfSRahul Lakkireddy ma_indr++; 1366270d39bfSRahul Lakkireddy } 1367270d39bfSRahul Lakkireddy 1368270d39bfSRahul Lakkireddy n = sizeof(t6_ma_ireg_array2) / (IREG_NUM_ELEM * sizeof(u32)); 1369270d39bfSRahul Lakkireddy for (i = 0; i < n; i++) { 1370270d39bfSRahul Lakkireddy struct ireg_field *ma_fli = &ma_indr->tp_pio; 1371270d39bfSRahul Lakkireddy u32 *buff = ma_indr->outbuf; 1372270d39bfSRahul Lakkireddy 1373270d39bfSRahul Lakkireddy ma_fli->ireg_addr = t6_ma_ireg_array2[i][0]; 1374270d39bfSRahul Lakkireddy ma_fli->ireg_data = t6_ma_ireg_array2[i][1]; 1375270d39bfSRahul Lakkireddy ma_fli->ireg_local_offset = t6_ma_ireg_array2[i][2]; 1376270d39bfSRahul Lakkireddy for (j = 0; j < t6_ma_ireg_array2[i][3]; j++) { 1377270d39bfSRahul Lakkireddy t4_read_indirect(padap, ma_fli->ireg_addr, 1378270d39bfSRahul Lakkireddy ma_fli->ireg_data, buff, 1, 1379270d39bfSRahul Lakkireddy ma_fli->ireg_local_offset); 1380270d39bfSRahul Lakkireddy buff++; 1381270d39bfSRahul Lakkireddy ma_fli->ireg_local_offset += 0x20; 1382270d39bfSRahul Lakkireddy } 1383270d39bfSRahul Lakkireddy ma_indr++; 1384270d39bfSRahul Lakkireddy } 1385270d39bfSRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 1386270d39bfSRahul Lakkireddy return rc; 1387270d39bfSRahul Lakkireddy } 1388270d39bfSRahul Lakkireddy 138927887bc7SRahul Lakkireddy int cudbg_collect_ulptx_la(struct cudbg_init *pdbg_init, 139027887bc7SRahul Lakkireddy struct cudbg_buffer *dbg_buff, 139127887bc7SRahul Lakkireddy struct cudbg_error *cudbg_err) 139227887bc7SRahul Lakkireddy { 139327887bc7SRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 139427887bc7SRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 139527887bc7SRahul Lakkireddy struct cudbg_ulptx_la *ulptx_la_buff; 139627887bc7SRahul Lakkireddy u32 i, j; 139727887bc7SRahul Lakkireddy int rc; 139827887bc7SRahul Lakkireddy 139927887bc7SRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, sizeof(struct cudbg_ulptx_la), 140027887bc7SRahul Lakkireddy &temp_buff); 140127887bc7SRahul Lakkireddy if (rc) 140227887bc7SRahul Lakkireddy return rc; 140327887bc7SRahul Lakkireddy 140427887bc7SRahul Lakkireddy ulptx_la_buff = (struct cudbg_ulptx_la *)temp_buff.data; 140527887bc7SRahul Lakkireddy for (i = 0; i < CUDBG_NUM_ULPTX; i++) { 140627887bc7SRahul Lakkireddy ulptx_la_buff->rdptr[i] = t4_read_reg(padap, 140727887bc7SRahul Lakkireddy ULP_TX_LA_RDPTR_0_A + 140827887bc7SRahul Lakkireddy 0x10 * i); 140927887bc7SRahul Lakkireddy ulptx_la_buff->wrptr[i] = t4_read_reg(padap, 141027887bc7SRahul Lakkireddy ULP_TX_LA_WRPTR_0_A + 141127887bc7SRahul Lakkireddy 0x10 * i); 141227887bc7SRahul Lakkireddy ulptx_la_buff->rddata[i] = t4_read_reg(padap, 141327887bc7SRahul Lakkireddy ULP_TX_LA_RDDATA_0_A + 141427887bc7SRahul Lakkireddy 0x10 * i); 141527887bc7SRahul Lakkireddy for (j = 0; j < CUDBG_NUM_ULPTX_READ; j++) 141627887bc7SRahul Lakkireddy ulptx_la_buff->rd_data[i][j] = 141727887bc7SRahul Lakkireddy t4_read_reg(padap, 141827887bc7SRahul Lakkireddy ULP_TX_LA_RDDATA_0_A + 0x10 * i); 141927887bc7SRahul Lakkireddy } 142027887bc7SRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 142127887bc7SRahul Lakkireddy return rc; 142227887bc7SRahul Lakkireddy } 142327887bc7SRahul Lakkireddy 1424270d39bfSRahul Lakkireddy int cudbg_collect_up_cim_indirect(struct cudbg_init *pdbg_init, 1425270d39bfSRahul Lakkireddy struct cudbg_buffer *dbg_buff, 1426270d39bfSRahul Lakkireddy struct cudbg_error *cudbg_err) 1427270d39bfSRahul Lakkireddy { 1428270d39bfSRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 1429270d39bfSRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 1430270d39bfSRahul Lakkireddy struct ireg_buf *up_cim; 1431270d39bfSRahul Lakkireddy int i, rc, n; 1432270d39bfSRahul Lakkireddy u32 size; 1433270d39bfSRahul Lakkireddy 1434270d39bfSRahul Lakkireddy n = sizeof(t5_up_cim_reg_array) / (IREG_NUM_ELEM * sizeof(u32)); 1435270d39bfSRahul Lakkireddy size = sizeof(struct ireg_buf) * n; 1436270d39bfSRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, size, &temp_buff); 1437270d39bfSRahul Lakkireddy if (rc) 1438270d39bfSRahul Lakkireddy return rc; 1439270d39bfSRahul Lakkireddy 1440270d39bfSRahul Lakkireddy up_cim = (struct ireg_buf *)temp_buff.data; 1441270d39bfSRahul Lakkireddy for (i = 0; i < n; i++) { 1442270d39bfSRahul Lakkireddy struct ireg_field *up_cim_reg = &up_cim->tp_pio; 1443270d39bfSRahul Lakkireddy u32 *buff = up_cim->outbuf; 1444270d39bfSRahul Lakkireddy 1445270d39bfSRahul Lakkireddy if (is_t5(padap->params.chip)) { 1446270d39bfSRahul Lakkireddy up_cim_reg->ireg_addr = t5_up_cim_reg_array[i][0]; 1447270d39bfSRahul Lakkireddy up_cim_reg->ireg_data = t5_up_cim_reg_array[i][1]; 1448270d39bfSRahul Lakkireddy up_cim_reg->ireg_local_offset = 1449270d39bfSRahul Lakkireddy t5_up_cim_reg_array[i][2]; 1450270d39bfSRahul Lakkireddy up_cim_reg->ireg_offset_range = 1451270d39bfSRahul Lakkireddy t5_up_cim_reg_array[i][3]; 1452270d39bfSRahul Lakkireddy } else if (is_t6(padap->params.chip)) { 1453270d39bfSRahul Lakkireddy up_cim_reg->ireg_addr = t6_up_cim_reg_array[i][0]; 1454270d39bfSRahul Lakkireddy up_cim_reg->ireg_data = t6_up_cim_reg_array[i][1]; 1455270d39bfSRahul Lakkireddy up_cim_reg->ireg_local_offset = 1456270d39bfSRahul Lakkireddy t6_up_cim_reg_array[i][2]; 1457270d39bfSRahul Lakkireddy up_cim_reg->ireg_offset_range = 1458270d39bfSRahul Lakkireddy t6_up_cim_reg_array[i][3]; 1459270d39bfSRahul Lakkireddy } 1460270d39bfSRahul Lakkireddy 1461270d39bfSRahul Lakkireddy rc = t4_cim_read(padap, up_cim_reg->ireg_local_offset, 1462270d39bfSRahul Lakkireddy up_cim_reg->ireg_offset_range, buff); 1463270d39bfSRahul Lakkireddy if (rc) { 1464270d39bfSRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 1465270d39bfSRahul Lakkireddy return rc; 1466270d39bfSRahul Lakkireddy } 1467270d39bfSRahul Lakkireddy up_cim++; 1468270d39bfSRahul Lakkireddy } 1469270d39bfSRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 1470270d39bfSRahul Lakkireddy return rc; 1471270d39bfSRahul Lakkireddy } 1472270d39bfSRahul Lakkireddy 1473db8cd7ceSRahul Lakkireddy int cudbg_collect_pbt_tables(struct cudbg_init *pdbg_init, 1474db8cd7ceSRahul Lakkireddy struct cudbg_buffer *dbg_buff, 1475db8cd7ceSRahul Lakkireddy struct cudbg_error *cudbg_err) 1476db8cd7ceSRahul Lakkireddy { 1477db8cd7ceSRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 1478db8cd7ceSRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 1479db8cd7ceSRahul Lakkireddy struct cudbg_pbt_tables *pbt; 1480db8cd7ceSRahul Lakkireddy int i, rc; 1481db8cd7ceSRahul Lakkireddy u32 addr; 1482db8cd7ceSRahul Lakkireddy 1483db8cd7ceSRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, sizeof(struct cudbg_pbt_tables), 1484db8cd7ceSRahul Lakkireddy &temp_buff); 1485db8cd7ceSRahul Lakkireddy if (rc) 1486db8cd7ceSRahul Lakkireddy return rc; 1487db8cd7ceSRahul Lakkireddy 1488db8cd7ceSRahul Lakkireddy pbt = (struct cudbg_pbt_tables *)temp_buff.data; 1489db8cd7ceSRahul Lakkireddy /* PBT dynamic entries */ 1490db8cd7ceSRahul Lakkireddy addr = CUDBG_CHAC_PBT_ADDR; 1491db8cd7ceSRahul Lakkireddy for (i = 0; i < CUDBG_PBT_DYNAMIC_ENTRIES; i++) { 1492db8cd7ceSRahul Lakkireddy rc = t4_cim_read(padap, addr + (i * 4), 1, 1493db8cd7ceSRahul Lakkireddy &pbt->pbt_dynamic[i]); 1494db8cd7ceSRahul Lakkireddy if (rc) { 1495db8cd7ceSRahul Lakkireddy cudbg_err->sys_err = rc; 1496db8cd7ceSRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 1497db8cd7ceSRahul Lakkireddy return rc; 1498db8cd7ceSRahul Lakkireddy } 1499db8cd7ceSRahul Lakkireddy } 1500db8cd7ceSRahul Lakkireddy 1501db8cd7ceSRahul Lakkireddy /* PBT static entries */ 1502db8cd7ceSRahul Lakkireddy /* static entries start when bit 6 is set */ 1503db8cd7ceSRahul Lakkireddy addr = CUDBG_CHAC_PBT_ADDR + (1 << 6); 1504db8cd7ceSRahul Lakkireddy for (i = 0; i < CUDBG_PBT_STATIC_ENTRIES; i++) { 1505db8cd7ceSRahul Lakkireddy rc = t4_cim_read(padap, addr + (i * 4), 1, 1506db8cd7ceSRahul Lakkireddy &pbt->pbt_static[i]); 1507db8cd7ceSRahul Lakkireddy if (rc) { 1508db8cd7ceSRahul Lakkireddy cudbg_err->sys_err = rc; 1509db8cd7ceSRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 1510db8cd7ceSRahul Lakkireddy return rc; 1511db8cd7ceSRahul Lakkireddy } 1512db8cd7ceSRahul Lakkireddy } 1513db8cd7ceSRahul Lakkireddy 1514db8cd7ceSRahul Lakkireddy /* LRF entries */ 1515db8cd7ceSRahul Lakkireddy addr = CUDBG_CHAC_PBT_LRF; 1516db8cd7ceSRahul Lakkireddy for (i = 0; i < CUDBG_LRF_ENTRIES; i++) { 1517db8cd7ceSRahul Lakkireddy rc = t4_cim_read(padap, addr + (i * 4), 1, 1518db8cd7ceSRahul Lakkireddy &pbt->lrf_table[i]); 1519db8cd7ceSRahul Lakkireddy if (rc) { 1520db8cd7ceSRahul Lakkireddy cudbg_err->sys_err = rc; 1521db8cd7ceSRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 1522db8cd7ceSRahul Lakkireddy return rc; 1523db8cd7ceSRahul Lakkireddy } 1524db8cd7ceSRahul Lakkireddy } 1525db8cd7ceSRahul Lakkireddy 1526db8cd7ceSRahul Lakkireddy /* PBT data entries */ 1527db8cd7ceSRahul Lakkireddy addr = CUDBG_CHAC_PBT_DATA; 1528db8cd7ceSRahul Lakkireddy for (i = 0; i < CUDBG_PBT_DATA_ENTRIES; i++) { 1529db8cd7ceSRahul Lakkireddy rc = t4_cim_read(padap, addr + (i * 4), 1, 1530db8cd7ceSRahul Lakkireddy &pbt->pbt_data[i]); 1531db8cd7ceSRahul Lakkireddy if (rc) { 1532db8cd7ceSRahul Lakkireddy cudbg_err->sys_err = rc; 1533db8cd7ceSRahul Lakkireddy cudbg_put_buff(&temp_buff, dbg_buff); 1534db8cd7ceSRahul Lakkireddy return rc; 1535db8cd7ceSRahul Lakkireddy } 1536db8cd7ceSRahul Lakkireddy } 1537db8cd7ceSRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 1538db8cd7ceSRahul Lakkireddy return rc; 1539db8cd7ceSRahul Lakkireddy } 1540db8cd7ceSRahul Lakkireddy 1541844d1b6fSRahul Lakkireddy int cudbg_collect_mbox_log(struct cudbg_init *pdbg_init, 1542844d1b6fSRahul Lakkireddy struct cudbg_buffer *dbg_buff, 1543844d1b6fSRahul Lakkireddy struct cudbg_error *cudbg_err) 1544844d1b6fSRahul Lakkireddy { 1545844d1b6fSRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 1546844d1b6fSRahul Lakkireddy struct cudbg_mbox_log *mboxlog = NULL; 1547844d1b6fSRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 1548844d1b6fSRahul Lakkireddy struct mbox_cmd_log *log = NULL; 1549844d1b6fSRahul Lakkireddy struct mbox_cmd *entry; 1550844d1b6fSRahul Lakkireddy unsigned int entry_idx; 1551844d1b6fSRahul Lakkireddy u16 mbox_cmds; 1552844d1b6fSRahul Lakkireddy int i, k, rc; 1553844d1b6fSRahul Lakkireddy u64 flit; 1554844d1b6fSRahul Lakkireddy u32 size; 1555844d1b6fSRahul Lakkireddy 1556844d1b6fSRahul Lakkireddy log = padap->mbox_log; 1557844d1b6fSRahul Lakkireddy mbox_cmds = padap->mbox_log->size; 1558844d1b6fSRahul Lakkireddy size = sizeof(struct cudbg_mbox_log) * mbox_cmds; 1559844d1b6fSRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, size, &temp_buff); 1560844d1b6fSRahul Lakkireddy if (rc) 1561844d1b6fSRahul Lakkireddy return rc; 1562844d1b6fSRahul Lakkireddy 1563844d1b6fSRahul Lakkireddy mboxlog = (struct cudbg_mbox_log *)temp_buff.data; 1564844d1b6fSRahul Lakkireddy for (k = 0; k < mbox_cmds; k++) { 1565844d1b6fSRahul Lakkireddy entry_idx = log->cursor + k; 1566844d1b6fSRahul Lakkireddy if (entry_idx >= log->size) 1567844d1b6fSRahul Lakkireddy entry_idx -= log->size; 1568844d1b6fSRahul Lakkireddy 1569844d1b6fSRahul Lakkireddy entry = mbox_cmd_log_entry(log, entry_idx); 1570844d1b6fSRahul Lakkireddy /* skip over unused entries */ 1571844d1b6fSRahul Lakkireddy if (entry->timestamp == 0) 1572844d1b6fSRahul Lakkireddy continue; 1573844d1b6fSRahul Lakkireddy 1574844d1b6fSRahul Lakkireddy memcpy(&mboxlog->entry, entry, sizeof(struct mbox_cmd)); 1575844d1b6fSRahul Lakkireddy for (i = 0; i < MBOX_LEN / 8; i++) { 1576844d1b6fSRahul Lakkireddy flit = entry->cmd[i]; 1577844d1b6fSRahul Lakkireddy mboxlog->hi[i] = (u32)(flit >> 32); 1578844d1b6fSRahul Lakkireddy mboxlog->lo[i] = (u32)flit; 1579844d1b6fSRahul Lakkireddy } 1580844d1b6fSRahul Lakkireddy mboxlog++; 1581844d1b6fSRahul Lakkireddy } 1582844d1b6fSRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 1583844d1b6fSRahul Lakkireddy return rc; 1584844d1b6fSRahul Lakkireddy } 1585270d39bfSRahul Lakkireddy 1586270d39bfSRahul Lakkireddy int cudbg_collect_hma_indirect(struct cudbg_init *pdbg_init, 1587270d39bfSRahul Lakkireddy struct cudbg_buffer *dbg_buff, 1588270d39bfSRahul Lakkireddy struct cudbg_error *cudbg_err) 1589270d39bfSRahul Lakkireddy { 1590270d39bfSRahul Lakkireddy struct adapter *padap = pdbg_init->adap; 1591270d39bfSRahul Lakkireddy struct cudbg_buffer temp_buff = { 0 }; 1592270d39bfSRahul Lakkireddy struct ireg_buf *hma_indr; 1593270d39bfSRahul Lakkireddy int i, rc, n; 1594270d39bfSRahul Lakkireddy u32 size; 1595270d39bfSRahul Lakkireddy 1596270d39bfSRahul Lakkireddy if (CHELSIO_CHIP_VERSION(padap->params.chip) < CHELSIO_T6) 1597270d39bfSRahul Lakkireddy return CUDBG_STATUS_ENTITY_NOT_FOUND; 1598270d39bfSRahul Lakkireddy 1599270d39bfSRahul Lakkireddy n = sizeof(t6_hma_ireg_array) / (IREG_NUM_ELEM * sizeof(u32)); 1600270d39bfSRahul Lakkireddy size = sizeof(struct ireg_buf) * n; 1601270d39bfSRahul Lakkireddy rc = cudbg_get_buff(dbg_buff, size, &temp_buff); 1602270d39bfSRahul Lakkireddy if (rc) 1603270d39bfSRahul Lakkireddy return rc; 1604270d39bfSRahul Lakkireddy 1605270d39bfSRahul Lakkireddy hma_indr = (struct ireg_buf *)temp_buff.data; 1606270d39bfSRahul Lakkireddy for (i = 0; i < n; i++) { 1607270d39bfSRahul Lakkireddy struct ireg_field *hma_fli = &hma_indr->tp_pio; 1608270d39bfSRahul Lakkireddy u32 *buff = hma_indr->outbuf; 1609270d39bfSRahul Lakkireddy 1610270d39bfSRahul Lakkireddy hma_fli->ireg_addr = t6_hma_ireg_array[i][0]; 1611270d39bfSRahul Lakkireddy hma_fli->ireg_data = t6_hma_ireg_array[i][1]; 1612270d39bfSRahul Lakkireddy hma_fli->ireg_local_offset = t6_hma_ireg_array[i][2]; 1613270d39bfSRahul Lakkireddy hma_fli->ireg_offset_range = t6_hma_ireg_array[i][3]; 1614270d39bfSRahul Lakkireddy t4_read_indirect(padap, hma_fli->ireg_addr, hma_fli->ireg_data, 1615270d39bfSRahul Lakkireddy buff, hma_fli->ireg_offset_range, 1616270d39bfSRahul Lakkireddy hma_fli->ireg_local_offset); 1617270d39bfSRahul Lakkireddy hma_indr++; 1618270d39bfSRahul Lakkireddy } 1619270d39bfSRahul Lakkireddy cudbg_write_and_release_buff(&temp_buff, dbg_buff); 1620270d39bfSRahul Lakkireddy return rc; 1621270d39bfSRahul Lakkireddy } 1622