cxgb4_cudbg.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. /*
  2. * Copyright (C) 2017 Chelsio Communications. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * The full GNU General Public License is included in this distribution in
  14. * the file called "COPYING".
  15. *
  16. */
  17. #include "t4_regs.h"
  18. #include "cxgb4.h"
  19. #include "cxgb4_cudbg.h"
  20. #include "cudbg_zlib.h"
  21. static const struct cxgb4_collect_entity cxgb4_collect_mem_dump[] = {
  22. { CUDBG_EDC0, cudbg_collect_edc0_meminfo },
  23. { CUDBG_EDC1, cudbg_collect_edc1_meminfo },
  24. { CUDBG_MC0, cudbg_collect_mc0_meminfo },
  25. { CUDBG_MC1, cudbg_collect_mc1_meminfo },
  26. { CUDBG_HMA, cudbg_collect_hma_meminfo },
  27. };
  28. static const struct cxgb4_collect_entity cxgb4_collect_hw_dump[] = {
  29. { CUDBG_MBOX_LOG, cudbg_collect_mbox_log },
  30. { CUDBG_DEV_LOG, cudbg_collect_fw_devlog },
  31. { CUDBG_REG_DUMP, cudbg_collect_reg_dump },
  32. { CUDBG_CIM_LA, cudbg_collect_cim_la },
  33. { CUDBG_CIM_MA_LA, cudbg_collect_cim_ma_la },
  34. { CUDBG_CIM_QCFG, cudbg_collect_cim_qcfg },
  35. { CUDBG_CIM_IBQ_TP0, cudbg_collect_cim_ibq_tp0 },
  36. { CUDBG_CIM_IBQ_TP1, cudbg_collect_cim_ibq_tp1 },
  37. { CUDBG_CIM_IBQ_ULP, cudbg_collect_cim_ibq_ulp },
  38. { CUDBG_CIM_IBQ_SGE0, cudbg_collect_cim_ibq_sge0 },
  39. { CUDBG_CIM_IBQ_SGE1, cudbg_collect_cim_ibq_sge1 },
  40. { CUDBG_CIM_IBQ_NCSI, cudbg_collect_cim_ibq_ncsi },
  41. { CUDBG_CIM_OBQ_ULP0, cudbg_collect_cim_obq_ulp0 },
  42. { CUDBG_CIM_OBQ_ULP1, cudbg_collect_cim_obq_ulp1 },
  43. { CUDBG_CIM_OBQ_ULP2, cudbg_collect_cim_obq_ulp2 },
  44. { CUDBG_CIM_OBQ_ULP3, cudbg_collect_cim_obq_ulp3 },
  45. { CUDBG_CIM_OBQ_SGE, cudbg_collect_cim_obq_sge },
  46. { CUDBG_CIM_OBQ_NCSI, cudbg_collect_cim_obq_ncsi },
  47. { CUDBG_RSS, cudbg_collect_rss },
  48. { CUDBG_RSS_VF_CONF, cudbg_collect_rss_vf_config },
  49. { CUDBG_PATH_MTU, cudbg_collect_path_mtu },
  50. { CUDBG_PM_STATS, cudbg_collect_pm_stats },
  51. { CUDBG_HW_SCHED, cudbg_collect_hw_sched },
  52. { CUDBG_TP_INDIRECT, cudbg_collect_tp_indirect },
  53. { CUDBG_SGE_INDIRECT, cudbg_collect_sge_indirect },
  54. { CUDBG_ULPRX_LA, cudbg_collect_ulprx_la },
  55. { CUDBG_TP_LA, cudbg_collect_tp_la },
  56. { CUDBG_MEMINFO, cudbg_collect_meminfo },
  57. { CUDBG_CIM_PIF_LA, cudbg_collect_cim_pif_la },
  58. { CUDBG_CLK, cudbg_collect_clk_info },
  59. { CUDBG_CIM_OBQ_RXQ0, cudbg_collect_obq_sge_rx_q0 },
  60. { CUDBG_CIM_OBQ_RXQ1, cudbg_collect_obq_sge_rx_q1 },
  61. { CUDBG_PCIE_INDIRECT, cudbg_collect_pcie_indirect },
  62. { CUDBG_PM_INDIRECT, cudbg_collect_pm_indirect },
  63. { CUDBG_TID_INFO, cudbg_collect_tid },
  64. { CUDBG_PCIE_CONFIG, cudbg_collect_pcie_config },
  65. { CUDBG_DUMP_CONTEXT, cudbg_collect_dump_context },
  66. { CUDBG_MPS_TCAM, cudbg_collect_mps_tcam },
  67. { CUDBG_VPD_DATA, cudbg_collect_vpd_data },
  68. { CUDBG_LE_TCAM, cudbg_collect_le_tcam },
  69. { CUDBG_CCTRL, cudbg_collect_cctrl },
  70. { CUDBG_MA_INDIRECT, cudbg_collect_ma_indirect },
  71. { CUDBG_ULPTX_LA, cudbg_collect_ulptx_la },
  72. { CUDBG_UP_CIM_INDIRECT, cudbg_collect_up_cim_indirect },
  73. { CUDBG_PBT_TABLE, cudbg_collect_pbt_tables },
  74. { CUDBG_HMA_INDIRECT, cudbg_collect_hma_indirect },
  75. };
  76. static u32 cxgb4_get_entity_length(struct adapter *adap, u32 entity)
  77. {
  78. struct cudbg_tcam tcam_region = { 0 };
  79. u32 value, n = 0, len = 0;
  80. switch (entity) {
  81. case CUDBG_REG_DUMP:
  82. switch (CHELSIO_CHIP_VERSION(adap->params.chip)) {
  83. case CHELSIO_T4:
  84. len = T4_REGMAP_SIZE;
  85. break;
  86. case CHELSIO_T5:
  87. case CHELSIO_T6:
  88. len = T5_REGMAP_SIZE;
  89. break;
  90. default:
  91. break;
  92. }
  93. break;
  94. case CUDBG_DEV_LOG:
  95. len = adap->params.devlog.size;
  96. break;
  97. case CUDBG_CIM_LA:
  98. if (is_t6(adap->params.chip)) {
  99. len = adap->params.cim_la_size / 10 + 1;
  100. len *= 10 * sizeof(u32);
  101. } else {
  102. len = adap->params.cim_la_size / 8;
  103. len *= 8 * sizeof(u32);
  104. }
  105. len += sizeof(u32); /* for reading CIM LA configuration */
  106. break;
  107. case CUDBG_CIM_MA_LA:
  108. len = 2 * CIM_MALA_SIZE * 5 * sizeof(u32);
  109. break;
  110. case CUDBG_CIM_QCFG:
  111. len = sizeof(struct cudbg_cim_qcfg);
  112. break;
  113. case CUDBG_CIM_IBQ_TP0:
  114. case CUDBG_CIM_IBQ_TP1:
  115. case CUDBG_CIM_IBQ_ULP:
  116. case CUDBG_CIM_IBQ_SGE0:
  117. case CUDBG_CIM_IBQ_SGE1:
  118. case CUDBG_CIM_IBQ_NCSI:
  119. len = CIM_IBQ_SIZE * 4 * sizeof(u32);
  120. break;
  121. case CUDBG_CIM_OBQ_ULP0:
  122. len = cudbg_cim_obq_size(adap, 0);
  123. break;
  124. case CUDBG_CIM_OBQ_ULP1:
  125. len = cudbg_cim_obq_size(adap, 1);
  126. break;
  127. case CUDBG_CIM_OBQ_ULP2:
  128. len = cudbg_cim_obq_size(adap, 2);
  129. break;
  130. case CUDBG_CIM_OBQ_ULP3:
  131. len = cudbg_cim_obq_size(adap, 3);
  132. break;
  133. case CUDBG_CIM_OBQ_SGE:
  134. len = cudbg_cim_obq_size(adap, 4);
  135. break;
  136. case CUDBG_CIM_OBQ_NCSI:
  137. len = cudbg_cim_obq_size(adap, 5);
  138. break;
  139. case CUDBG_CIM_OBQ_RXQ0:
  140. len = cudbg_cim_obq_size(adap, 6);
  141. break;
  142. case CUDBG_CIM_OBQ_RXQ1:
  143. len = cudbg_cim_obq_size(adap, 7);
  144. break;
  145. case CUDBG_EDC0:
  146. value = t4_read_reg(adap, MA_TARGET_MEM_ENABLE_A);
  147. if (value & EDRAM0_ENABLE_F) {
  148. value = t4_read_reg(adap, MA_EDRAM0_BAR_A);
  149. len = EDRAM0_SIZE_G(value);
  150. }
  151. len = cudbg_mbytes_to_bytes(len);
  152. break;
  153. case CUDBG_EDC1:
  154. value = t4_read_reg(adap, MA_TARGET_MEM_ENABLE_A);
  155. if (value & EDRAM1_ENABLE_F) {
  156. value = t4_read_reg(adap, MA_EDRAM1_BAR_A);
  157. len = EDRAM1_SIZE_G(value);
  158. }
  159. len = cudbg_mbytes_to_bytes(len);
  160. break;
  161. case CUDBG_MC0:
  162. value = t4_read_reg(adap, MA_TARGET_MEM_ENABLE_A);
  163. if (value & EXT_MEM0_ENABLE_F) {
  164. value = t4_read_reg(adap, MA_EXT_MEMORY0_BAR_A);
  165. len = EXT_MEM0_SIZE_G(value);
  166. }
  167. len = cudbg_mbytes_to_bytes(len);
  168. break;
  169. case CUDBG_MC1:
  170. value = t4_read_reg(adap, MA_TARGET_MEM_ENABLE_A);
  171. if (value & EXT_MEM1_ENABLE_F) {
  172. value = t4_read_reg(adap, MA_EXT_MEMORY1_BAR_A);
  173. len = EXT_MEM1_SIZE_G(value);
  174. }
  175. len = cudbg_mbytes_to_bytes(len);
  176. break;
  177. case CUDBG_RSS:
  178. len = t4_chip_rss_size(adap) * sizeof(u16);
  179. break;
  180. case CUDBG_RSS_VF_CONF:
  181. len = adap->params.arch.vfcount *
  182. sizeof(struct cudbg_rss_vf_conf);
  183. break;
  184. case CUDBG_PATH_MTU:
  185. len = NMTUS * sizeof(u16);
  186. break;
  187. case CUDBG_PM_STATS:
  188. len = sizeof(struct cudbg_pm_stats);
  189. break;
  190. case CUDBG_HW_SCHED:
  191. len = sizeof(struct cudbg_hw_sched);
  192. break;
  193. case CUDBG_TP_INDIRECT:
  194. switch (CHELSIO_CHIP_VERSION(adap->params.chip)) {
  195. case CHELSIO_T5:
  196. n = sizeof(t5_tp_pio_array) +
  197. sizeof(t5_tp_tm_pio_array) +
  198. sizeof(t5_tp_mib_index_array);
  199. break;
  200. case CHELSIO_T6:
  201. n = sizeof(t6_tp_pio_array) +
  202. sizeof(t6_tp_tm_pio_array) +
  203. sizeof(t6_tp_mib_index_array);
  204. break;
  205. default:
  206. break;
  207. }
  208. n = n / (IREG_NUM_ELEM * sizeof(u32));
  209. len = sizeof(struct ireg_buf) * n;
  210. break;
  211. case CUDBG_SGE_INDIRECT:
  212. len = sizeof(struct ireg_buf) * 2 +
  213. sizeof(struct sge_qbase_reg_field);
  214. break;
  215. case CUDBG_ULPRX_LA:
  216. len = sizeof(struct cudbg_ulprx_la);
  217. break;
  218. case CUDBG_TP_LA:
  219. len = sizeof(struct cudbg_tp_la) + TPLA_SIZE * sizeof(u64);
  220. break;
  221. case CUDBG_MEMINFO:
  222. len = sizeof(struct cudbg_ver_hdr) +
  223. sizeof(struct cudbg_meminfo);
  224. break;
  225. case CUDBG_CIM_PIF_LA:
  226. len = sizeof(struct cudbg_cim_pif_la);
  227. len += 2 * CIM_PIFLA_SIZE * 6 * sizeof(u32);
  228. break;
  229. case CUDBG_CLK:
  230. len = sizeof(struct cudbg_clk_info);
  231. break;
  232. case CUDBG_PCIE_INDIRECT:
  233. n = sizeof(t5_pcie_pdbg_array) / (IREG_NUM_ELEM * sizeof(u32));
  234. len = sizeof(struct ireg_buf) * n * 2;
  235. break;
  236. case CUDBG_PM_INDIRECT:
  237. n = sizeof(t5_pm_rx_array) / (IREG_NUM_ELEM * sizeof(u32));
  238. len = sizeof(struct ireg_buf) * n * 2;
  239. break;
  240. case CUDBG_TID_INFO:
  241. len = sizeof(struct cudbg_tid_info_region_rev1);
  242. break;
  243. case CUDBG_PCIE_CONFIG:
  244. len = sizeof(u32) * CUDBG_NUM_PCIE_CONFIG_REGS;
  245. break;
  246. case CUDBG_DUMP_CONTEXT:
  247. len = cudbg_dump_context_size(adap);
  248. break;
  249. case CUDBG_MPS_TCAM:
  250. len = sizeof(struct cudbg_mps_tcam) *
  251. adap->params.arch.mps_tcam_size;
  252. break;
  253. case CUDBG_VPD_DATA:
  254. len = sizeof(struct cudbg_vpd_data);
  255. break;
  256. case CUDBG_LE_TCAM:
  257. cudbg_fill_le_tcam_info(adap, &tcam_region);
  258. len = sizeof(struct cudbg_tcam) +
  259. sizeof(struct cudbg_tid_data) * tcam_region.max_tid;
  260. break;
  261. case CUDBG_CCTRL:
  262. len = sizeof(u16) * NMTUS * NCCTRL_WIN;
  263. break;
  264. case CUDBG_MA_INDIRECT:
  265. if (CHELSIO_CHIP_VERSION(adap->params.chip) > CHELSIO_T5) {
  266. n = sizeof(t6_ma_ireg_array) /
  267. (IREG_NUM_ELEM * sizeof(u32));
  268. len = sizeof(struct ireg_buf) * n * 2;
  269. }
  270. break;
  271. case CUDBG_ULPTX_LA:
  272. len = sizeof(struct cudbg_ver_hdr) +
  273. sizeof(struct cudbg_ulptx_la);
  274. break;
  275. case CUDBG_UP_CIM_INDIRECT:
  276. n = 0;
  277. if (is_t5(adap->params.chip))
  278. n = sizeof(t5_up_cim_reg_array) /
  279. ((IREG_NUM_ELEM + 1) * sizeof(u32));
  280. else if (is_t6(adap->params.chip))
  281. n = sizeof(t6_up_cim_reg_array) /
  282. ((IREG_NUM_ELEM + 1) * sizeof(u32));
  283. len = sizeof(struct ireg_buf) * n;
  284. break;
  285. case CUDBG_PBT_TABLE:
  286. len = sizeof(struct cudbg_pbt_tables);
  287. break;
  288. case CUDBG_MBOX_LOG:
  289. len = sizeof(struct cudbg_mbox_log) * adap->mbox_log->size;
  290. break;
  291. case CUDBG_HMA_INDIRECT:
  292. if (CHELSIO_CHIP_VERSION(adap->params.chip) > CHELSIO_T5) {
  293. n = sizeof(t6_hma_ireg_array) /
  294. (IREG_NUM_ELEM * sizeof(u32));
  295. len = sizeof(struct ireg_buf) * n;
  296. }
  297. break;
  298. case CUDBG_HMA:
  299. value = t4_read_reg(adap, MA_TARGET_MEM_ENABLE_A);
  300. if (value & HMA_MUX_F) {
  301. /* In T6, there's no MC1. So, HMA shares MC1
  302. * address space.
  303. */
  304. value = t4_read_reg(adap, MA_EXT_MEMORY1_BAR_A);
  305. len = EXT_MEM1_SIZE_G(value);
  306. }
  307. len = cudbg_mbytes_to_bytes(len);
  308. break;
  309. default:
  310. break;
  311. }
  312. return len;
  313. }
  314. u32 cxgb4_get_dump_length(struct adapter *adap, u32 flag)
  315. {
  316. u32 i, entity;
  317. u32 len = 0;
  318. u32 wsize;
  319. if (flag & CXGB4_ETH_DUMP_HW) {
  320. for (i = 0; i < ARRAY_SIZE(cxgb4_collect_hw_dump); i++) {
  321. entity = cxgb4_collect_hw_dump[i].entity;
  322. len += cxgb4_get_entity_length(adap, entity);
  323. }
  324. }
  325. if (flag & CXGB4_ETH_DUMP_MEM) {
  326. for (i = 0; i < ARRAY_SIZE(cxgb4_collect_mem_dump); i++) {
  327. entity = cxgb4_collect_mem_dump[i].entity;
  328. len += cxgb4_get_entity_length(adap, entity);
  329. }
  330. }
  331. /* If compression is enabled, a smaller destination buffer is enough */
  332. wsize = cudbg_get_workspace_size();
  333. if (wsize && len > CUDBG_DUMP_BUFF_SIZE)
  334. len = CUDBG_DUMP_BUFF_SIZE;
  335. return len;
  336. }
  337. static void cxgb4_cudbg_collect_entity(struct cudbg_init *pdbg_init,
  338. struct cudbg_buffer *dbg_buff,
  339. const struct cxgb4_collect_entity *e_arr,
  340. u32 arr_size, void *buf, u32 *tot_size)
  341. {
  342. struct cudbg_error cudbg_err = { 0 };
  343. struct cudbg_entity_hdr *entity_hdr;
  344. u32 i, total_size = 0;
  345. int ret;
  346. for (i = 0; i < arr_size; i++) {
  347. const struct cxgb4_collect_entity *e = &e_arr[i];
  348. entity_hdr = cudbg_get_entity_hdr(buf, e->entity);
  349. entity_hdr->entity_type = e->entity;
  350. entity_hdr->start_offset = dbg_buff->offset;
  351. memset(&cudbg_err, 0, sizeof(struct cudbg_error));
  352. ret = e->collect_cb(pdbg_init, dbg_buff, &cudbg_err);
  353. if (ret) {
  354. entity_hdr->size = 0;
  355. dbg_buff->offset = entity_hdr->start_offset;
  356. } else {
  357. cudbg_align_debug_buffer(dbg_buff, entity_hdr);
  358. }
  359. /* Log error and continue with next entity */
  360. if (cudbg_err.sys_err)
  361. ret = CUDBG_SYSTEM_ERROR;
  362. entity_hdr->hdr_flags = ret;
  363. entity_hdr->sys_err = cudbg_err.sys_err;
  364. entity_hdr->sys_warn = cudbg_err.sys_warn;
  365. total_size += entity_hdr->size;
  366. }
  367. *tot_size += total_size;
  368. }
  369. static int cudbg_alloc_compress_buff(struct cudbg_init *pdbg_init)
  370. {
  371. u32 workspace_size;
  372. workspace_size = cudbg_get_workspace_size();
  373. pdbg_init->compress_buff = vzalloc(CUDBG_COMPRESS_BUFF_SIZE +
  374. workspace_size);
  375. if (!pdbg_init->compress_buff)
  376. return -ENOMEM;
  377. pdbg_init->compress_buff_size = CUDBG_COMPRESS_BUFF_SIZE;
  378. pdbg_init->workspace = (u8 *)pdbg_init->compress_buff +
  379. CUDBG_COMPRESS_BUFF_SIZE - workspace_size;
  380. return 0;
  381. }
  382. static void cudbg_free_compress_buff(struct cudbg_init *pdbg_init)
  383. {
  384. if (pdbg_init->compress_buff)
  385. vfree(pdbg_init->compress_buff);
  386. }
  387. int cxgb4_cudbg_collect(struct adapter *adap, void *buf, u32 *buf_size,
  388. u32 flag)
  389. {
  390. struct cudbg_buffer dbg_buff = { 0 };
  391. u32 size, min_size, total_size = 0;
  392. struct cudbg_init cudbg_init;
  393. struct cudbg_hdr *cudbg_hdr;
  394. int rc;
  395. size = *buf_size;
  396. memset(&cudbg_init, 0, sizeof(struct cudbg_init));
  397. cudbg_init.adap = adap;
  398. cudbg_init.outbuf = buf;
  399. cudbg_init.outbuf_size = size;
  400. dbg_buff.data = buf;
  401. dbg_buff.size = size;
  402. dbg_buff.offset = 0;
  403. cudbg_hdr = (struct cudbg_hdr *)buf;
  404. cudbg_hdr->signature = CUDBG_SIGNATURE;
  405. cudbg_hdr->hdr_len = sizeof(struct cudbg_hdr);
  406. cudbg_hdr->major_ver = CUDBG_MAJOR_VERSION;
  407. cudbg_hdr->minor_ver = CUDBG_MINOR_VERSION;
  408. cudbg_hdr->max_entities = CUDBG_MAX_ENTITY;
  409. cudbg_hdr->chip_ver = adap->params.chip;
  410. cudbg_hdr->dump_type = CUDBG_DUMP_TYPE_MINI;
  411. min_size = sizeof(struct cudbg_hdr) +
  412. sizeof(struct cudbg_entity_hdr) *
  413. cudbg_hdr->max_entities;
  414. if (size < min_size)
  415. return -ENOMEM;
  416. rc = cudbg_get_workspace_size();
  417. if (rc) {
  418. /* Zlib available. So, use zlib deflate */
  419. cudbg_init.compress_type = CUDBG_COMPRESSION_ZLIB;
  420. rc = cudbg_alloc_compress_buff(&cudbg_init);
  421. if (rc) {
  422. /* Ignore error and continue without compression. */
  423. dev_warn(adap->pdev_dev,
  424. "Fail allocating compression buffer ret: %d. Continuing without compression.\n",
  425. rc);
  426. cudbg_init.compress_type = CUDBG_COMPRESSION_NONE;
  427. rc = 0;
  428. }
  429. } else {
  430. cudbg_init.compress_type = CUDBG_COMPRESSION_NONE;
  431. }
  432. cudbg_hdr->compress_type = cudbg_init.compress_type;
  433. dbg_buff.offset += min_size;
  434. total_size = dbg_buff.offset;
  435. if (flag & CXGB4_ETH_DUMP_HW)
  436. cxgb4_cudbg_collect_entity(&cudbg_init, &dbg_buff,
  437. cxgb4_collect_hw_dump,
  438. ARRAY_SIZE(cxgb4_collect_hw_dump),
  439. buf,
  440. &total_size);
  441. if (flag & CXGB4_ETH_DUMP_MEM)
  442. cxgb4_cudbg_collect_entity(&cudbg_init, &dbg_buff,
  443. cxgb4_collect_mem_dump,
  444. ARRAY_SIZE(cxgb4_collect_mem_dump),
  445. buf,
  446. &total_size);
  447. cudbg_free_compress_buff(&cudbg_init);
  448. cudbg_hdr->data_len = total_size;
  449. if (cudbg_init.compress_type != CUDBG_COMPRESSION_NONE)
  450. *buf_size = size;
  451. else
  452. *buf_size = total_size;
  453. return 0;
  454. }
  455. void cxgb4_init_ethtool_dump(struct adapter *adapter)
  456. {
  457. adapter->eth_dump.flag = CXGB4_ETH_DUMP_NONE;
  458. adapter->eth_dump.version = adapter->params.fw_vers;
  459. adapter->eth_dump.len = 0;
  460. }
  461. static int cxgb4_cudbg_vmcoredd_collect(struct vmcoredd_data *data, void *buf)
  462. {
  463. struct adapter *adap = container_of(data, struct adapter, vmcoredd);
  464. u32 len = data->size;
  465. return cxgb4_cudbg_collect(adap, buf, &len, CXGB4_ETH_DUMP_ALL);
  466. }
  467. int cxgb4_cudbg_vmcore_add_dump(struct adapter *adap)
  468. {
  469. struct vmcoredd_data *data = &adap->vmcoredd;
  470. u32 len;
  471. len = sizeof(struct cudbg_hdr) +
  472. sizeof(struct cudbg_entity_hdr) * CUDBG_MAX_ENTITY;
  473. len += CUDBG_DUMP_BUFF_SIZE;
  474. data->size = len;
  475. snprintf(data->dump_name, sizeof(data->dump_name), "%s_%s",
  476. cxgb4_driver_name, adap->name);
  477. data->vmcoredd_callback = cxgb4_cudbg_vmcoredd_collect;
  478. return vmcore_add_device_dump(data);
  479. }