@@ -25,8 +25,40 @@ static const u16 bnxt_bstore_to_seg_id[] = {
2525 [BNXT_CTX_FTQM ] = BNXT_CTX_MEM_SEG_FTQM ,
2626 [BNXT_CTX_MRAV ] = BNXT_CTX_MEM_SEG_MRAV ,
2727 [BNXT_CTX_TIM ] = BNXT_CTX_MEM_SEG_TIM ,
28+ [BNXT_CTX_SRT ] = BNXT_CTX_MEM_SEG_SRT ,
29+ [BNXT_CTX_SRT2 ] = BNXT_CTX_MEM_SEG_SRT2 ,
30+ [BNXT_CTX_CRT ] = BNXT_CTX_MEM_SEG_CRT ,
31+ [BNXT_CTX_CRT2 ] = BNXT_CTX_MEM_SEG_CRT2 ,
32+ [BNXT_CTX_RIGP0 ] = BNXT_CTX_MEM_SEG_RIGP0 ,
33+ [BNXT_CTX_L2HWRM ] = BNXT_CTX_MEM_SEG_L2HWRM ,
34+ [BNXT_CTX_REHWRM ] = BNXT_CTX_MEM_SEG_REHWRM ,
35+ [BNXT_CTX_CA0 ] = BNXT_CTX_MEM_SEG_CA0 ,
36+ [BNXT_CTX_CA1 ] = BNXT_CTX_MEM_SEG_CA1 ,
37+ [BNXT_CTX_CA2 ] = BNXT_CTX_MEM_SEG_CA2 ,
38+ [BNXT_CTX_RIGP1 ] = BNXT_CTX_MEM_SEG_RIGP1 ,
2839};
2940
41+ static int bnxt_dbg_hwrm_log_buffer_flush (struct bnxt * bp , u16 type , u32 flags ,
42+ u32 * offset )
43+ {
44+ struct hwrm_dbg_log_buffer_flush_output * resp ;
45+ struct hwrm_dbg_log_buffer_flush_input * req ;
46+ int rc ;
47+
48+ rc = hwrm_req_init (bp , req , HWRM_DBG_LOG_BUFFER_FLUSH );
49+ if (rc )
50+ return rc ;
51+
52+ req -> flags = cpu_to_le32 (flags );
53+ req -> type = cpu_to_le16 (type );
54+ resp = hwrm_req_hold (bp , req );
55+ rc = hwrm_req_send (bp , req );
56+ if (!rc )
57+ * offset = le32_to_cpu (resp -> current_buffer_offset );
58+ hwrm_req_drop (bp , req );
59+ return rc ;
60+ }
61+
3062static int bnxt_hwrm_dbg_dma_data (struct bnxt * bp , void * msg ,
3163 struct bnxt_hwrm_dbg_dma_info * info )
3264{
@@ -279,9 +311,29 @@ bnxt_fill_coredump_record(struct bnxt *bp, struct bnxt_coredump_record *record,
279311 record -> ioctl_high_version = 0 ;
280312}
281313
314+ static void bnxt_fill_drv_seg_record (struct bnxt * bp ,
315+ struct bnxt_driver_segment_record * record ,
316+ struct bnxt_ctx_mem_type * ctxm , u16 type )
317+ {
318+ struct bnxt_bs_trace_info * bs_trace = & bp -> bs_trace [type ];
319+ u32 offset = 0 ;
320+ int rc = 0 ;
321+
322+ rc = bnxt_dbg_hwrm_log_buffer_flush (bp , type , 0 , & offset );
323+ if (rc )
324+ return ;
325+
326+ bnxt_bs_trace_check_wrap (bs_trace , offset );
327+ record -> max_entries = cpu_to_le32 (ctxm -> max_entries );
328+ record -> entry_size = cpu_to_le32 (ctxm -> entry_size );
329+ record -> offset = cpu_to_le32 (bs_trace -> last_offset );
330+ record -> wrapped = bs_trace -> wrapped ;
331+ }
332+
282333static u32 bnxt_get_ctx_coredump (struct bnxt * bp , void * buf , u32 offset ,
283334 u32 * segs )
284335{
336+ struct bnxt_driver_segment_record record = {};
285337 struct bnxt_coredump_segment_hdr seg_hdr ;
286338 struct bnxt_ctx_mem_info * ctx = bp -> ctx ;
287339 u32 comp_id = BNXT_DRV_COMP_ID ;
@@ -295,22 +347,33 @@ static u32 bnxt_get_ctx_coredump(struct bnxt *bp, void *buf, u32 offset,
295347
296348 if (buf )
297349 buf += offset ;
298- for (type = 0 ; type <= BNXT_CTX_TIM ; type ++ ) {
350+ for (type = 0 ; type <= BNXT_CTX_RIGP1 ; type ++ ) {
299351 struct bnxt_ctx_mem_type * ctxm = & ctx -> ctx_arr [type ];
352+ bool trace = bnxt_bs_trace_avail (bp , type );
300353 u32 seg_id = bnxt_bstore_to_seg_id [type ];
301- size_t seg_len ;
354+ size_t seg_len , extra_hlen = 0 ;
302355
303- if (!ctxm -> entry_size || ! ctxm -> pg_info || !seg_id )
356+ if (!ctxm -> mem_valid || !seg_id )
304357 continue ;
305358
359+ if (trace )
360+ extra_hlen = BNXT_SEG_RCD_LEN ;
306361 if (buf )
307- data = buf + BNXT_SEG_HDR_LEN ;
308- seg_len = bnxt_copy_ctx_mem (bp , ctxm , data , 0 );
362+ data = buf + BNXT_SEG_HDR_LEN + extra_hlen ;
363+ seg_len = bnxt_copy_ctx_mem (bp , ctxm , data , 0 ) + extra_hlen ;
309364 if (buf ) {
310365 bnxt_fill_coredump_seg_hdr (bp , & seg_hdr , NULL , seg_len ,
311366 0 , 0 , 0 , comp_id , seg_id );
312367 memcpy (buf , & seg_hdr , BNXT_SEG_HDR_LEN );
313- buf += BNXT_SEG_HDR_LEN + seg_len ;
368+ buf += BNXT_SEG_HDR_LEN ;
369+ if (trace ) {
370+ u16 trace_type = bnxt_bstore_to_trace [type ];
371+
372+ bnxt_fill_drv_seg_record (bp , & record , ctxm ,
373+ trace_type );
374+ memcpy (buf , & record , BNXT_SEG_RCD_LEN );
375+ }
376+ buf += seg_len ;
314377 }
315378 len += BNXT_SEG_HDR_LEN + seg_len ;
316379 * segs += 1 ;
0 commit comments