|
15 | 15 | #include "bnxt_hwrm.h"
|
16 | 16 | #include "bnxt_coredump.h"
|
17 | 17 |
|
| 18 | +static const u16 bnxt_bstore_to_seg_id[] = { |
| 19 | + [BNXT_CTX_QP] = BNXT_CTX_MEM_SEG_QP, |
| 20 | + [BNXT_CTX_SRQ] = BNXT_CTX_MEM_SEG_SRQ, |
| 21 | + [BNXT_CTX_CQ] = BNXT_CTX_MEM_SEG_CQ, |
| 22 | + [BNXT_CTX_VNIC] = BNXT_CTX_MEM_SEG_VNIC, |
| 23 | + [BNXT_CTX_STAT] = BNXT_CTX_MEM_SEG_STAT, |
| 24 | + [BNXT_CTX_STQM] = BNXT_CTX_MEM_SEG_STQM, |
| 25 | + [BNXT_CTX_FTQM] = BNXT_CTX_MEM_SEG_FTQM, |
| 26 | + [BNXT_CTX_MRAV] = BNXT_CTX_MEM_SEG_MRAV, |
| 27 | + [BNXT_CTX_TIM] = BNXT_CTX_MEM_SEG_TIM, |
| 28 | +}; |
| 29 | + |
18 | 30 | static int bnxt_hwrm_dbg_dma_data(struct bnxt *bp, void *msg,
|
19 | 31 | struct bnxt_hwrm_dbg_dma_info *info)
|
20 | 32 | {
|
@@ -267,7 +279,47 @@ bnxt_fill_coredump_record(struct bnxt *bp, struct bnxt_coredump_record *record,
|
267 | 279 | record->ioctl_high_version = 0;
|
268 | 280 | }
|
269 | 281 |
|
270 |
| -static int __bnxt_get_coredump(struct bnxt *bp, void *buf, u32 *dump_len) |
| 282 | +static u32 bnxt_get_ctx_coredump(struct bnxt *bp, void *buf, u32 offset, |
| 283 | + u32 *segs) |
| 284 | +{ |
| 285 | + struct bnxt_coredump_segment_hdr seg_hdr; |
| 286 | + struct bnxt_ctx_mem_info *ctx = bp->ctx; |
| 287 | + u32 comp_id = BNXT_DRV_COMP_ID; |
| 288 | + void *data = NULL; |
| 289 | + size_t len = 0; |
| 290 | + u16 type; |
| 291 | + |
| 292 | + *segs = 0; |
| 293 | + if (!ctx) |
| 294 | + return 0; |
| 295 | + |
| 296 | + if (buf) |
| 297 | + buf += offset; |
| 298 | + for (type = 0 ; type <= BNXT_CTX_TIM; type++) { |
| 299 | + struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type]; |
| 300 | + u32 seg_id = bnxt_bstore_to_seg_id[type]; |
| 301 | + size_t seg_len; |
| 302 | + |
| 303 | + if (!ctxm->entry_size || !ctxm->pg_info || !seg_id) |
| 304 | + continue; |
| 305 | + |
| 306 | + if (buf) |
| 307 | + data = buf + BNXT_SEG_HDR_LEN; |
| 308 | + seg_len = bnxt_copy_ctx_mem(bp, ctxm, data, 0); |
| 309 | + if (buf) { |
| 310 | + bnxt_fill_coredump_seg_hdr(bp, &seg_hdr, NULL, seg_len, |
| 311 | + 0, 0, 0, comp_id, seg_id); |
| 312 | + memcpy(buf, &seg_hdr, BNXT_SEG_HDR_LEN); |
| 313 | + buf += BNXT_SEG_HDR_LEN + seg_len; |
| 314 | + } |
| 315 | + len += BNXT_SEG_HDR_LEN + seg_len; |
| 316 | + *segs += 1; |
| 317 | + } |
| 318 | + return len; |
| 319 | +} |
| 320 | + |
| 321 | +static int __bnxt_get_coredump(struct bnxt *bp, u16 dump_type, void *buf, |
| 322 | + u32 *dump_len) |
271 | 323 | {
|
272 | 324 | u32 ver_get_resp_len = sizeof(struct hwrm_ver_get_output);
|
273 | 325 | u32 offset = 0, seg_hdr_len, seg_record_len, buf_len = 0;
|
@@ -298,6 +350,18 @@ static int __bnxt_get_coredump(struct bnxt *bp, void *buf, u32 *dump_len)
|
298 | 350 | offset += ver_get_resp_len;
|
299 | 351 | }
|
300 | 352 |
|
| 353 | + if (dump_type == BNXT_DUMP_DRIVER) { |
| 354 | + u32 drv_len, segs = 0; |
| 355 | + |
| 356 | + drv_len = bnxt_get_ctx_coredump(bp, buf, offset, &segs); |
| 357 | + *dump_len += drv_len; |
| 358 | + offset += drv_len; |
| 359 | + if (buf) |
| 360 | + coredump.total_segs += segs; |
| 361 | + goto err; |
| 362 | + } |
| 363 | + |
| 364 | + seg_record_len = sizeof(*seg_record); |
301 | 365 | rc = bnxt_hwrm_dbg_coredump_list(bp, &coredump);
|
302 | 366 | if (rc) {
|
303 | 367 | netdev_err(bp->dev, "Failed to get coredump segment list\n");
|
@@ -442,7 +506,7 @@ int bnxt_get_coredump(struct bnxt *bp, u16 dump_type, void *buf, u32 *dump_len)
|
442 | 506 | else
|
443 | 507 | return -EOPNOTSUPP;
|
444 | 508 | } else {
|
445 |
| - return __bnxt_get_coredump(bp, buf, dump_len); |
| 509 | + return __bnxt_get_coredump(bp, dump_type, buf, dump_len); |
446 | 510 | }
|
447 | 511 | }
|
448 | 512 |
|
@@ -512,9 +576,12 @@ u32 bnxt_get_coredump_length(struct bnxt *bp, u16 dump_type)
|
512 | 576 | return bp->fw_crash_len;
|
513 | 577 | }
|
514 | 578 |
|
515 |
| - if (bnxt_hwrm_get_dump_len(bp, dump_type, &len)) { |
516 |
| - if (dump_type != BNXT_DUMP_CRASH) |
517 |
| - __bnxt_get_coredump(bp, NULL, &len); |
| 579 | + if (dump_type != BNXT_DUMP_DRIVER) { |
| 580 | + if (!bnxt_hwrm_get_dump_len(bp, dump_type, &len)) |
| 581 | + return len; |
518 | 582 | }
|
| 583 | + if (dump_type != BNXT_DUMP_CRASH) |
| 584 | + __bnxt_get_coredump(bp, dump_type, NULL, &len); |
| 585 | + |
519 | 586 | return len;
|
520 | 587 | }
|
0 commit comments