@@ -416,6 +416,32 @@ hwrm_update_token(struct bnxt *bp, u16 seq_id, enum bnxt_hwrm_wait_state state)
416416 netdev_err (bp -> dev , "Invalid hwrm seq id %d\n" , seq_id );
417417}
418418
419+ static void hwrm_req_dbg (struct bnxt * bp , struct input * req )
420+ {
421+ u32 ring = le16_to_cpu (req -> cmpl_ring );
422+ u32 type = le16_to_cpu (req -> req_type );
423+ u32 tgt = le16_to_cpu (req -> target_id );
424+ u32 seq = le16_to_cpu (req -> seq_id );
425+ char opt [32 ] = "\n" ;
426+
427+ if (unlikely (ring != (u16 )BNXT_HWRM_NO_CMPL_RING ))
428+ snprintf (opt , 16 , " ring %d\n" , ring );
429+
430+ if (unlikely (tgt != BNXT_HWRM_TARGET ))
431+ snprintf (opt + strlen (opt ) - 1 , 16 , " tgt 0x%x\n" , tgt );
432+
433+ netdev_dbg (bp -> dev , "sent hwrm req_type 0x%x seq id 0x%x%s" ,
434+ type , seq , opt );
435+ }
436+
437+ #define hwrm_err (bp , ctx , fmt , ...) \
438+ do { \
439+ if ((ctx)->flags & BNXT_HWRM_CTX_SILENT) \
440+ netdev_dbg((bp)->dev, fmt, __VA_ARGS__); \
441+ else \
442+ netdev_err((bp)->dev, fmt, __VA_ARGS__); \
443+ } while (0)
444+
419445static int __hwrm_send (struct bnxt * bp , struct bnxt_hwrm_ctx * ctx )
420446{
421447 u32 doorbell_offset = BNXT_GRCPF_REG_CHIMP_COMM_TRIGGER ;
@@ -436,8 +462,11 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
436462 memset (ctx -> resp , 0 , PAGE_SIZE );
437463
438464 req_type = le16_to_cpu (ctx -> req -> req_type );
439- if (BNXT_NO_FW_ACCESS (bp ) && req_type != HWRM_FUNC_RESET )
465+ if (BNXT_NO_FW_ACCESS (bp ) && req_type != HWRM_FUNC_RESET ) {
466+ netdev_dbg (bp -> dev , "hwrm req_type 0x%x skipped, FW channel down\n" ,
467+ req_type );
440468 goto exit ;
469+ }
441470
442471 if (msg_len > BNXT_HWRM_MAX_REQ_LEN &&
443472 msg_len > bp -> hwrm_max_ext_req_len ) {
@@ -490,6 +519,8 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
490519 /* Ring channel doorbell */
491520 writel (1 , bp -> bar0 + doorbell_offset );
492521
522+ hwrm_req_dbg (bp , ctx -> req );
523+
493524 if (!pci_is_enabled (bp -> pdev )) {
494525 rc = - ENODEV ;
495526 goto exit ;
@@ -531,9 +562,8 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
531562 }
532563
533564 if (READ_ONCE (token -> state ) != BNXT_HWRM_COMPLETE ) {
534- if (!(ctx -> flags & BNXT_HWRM_CTX_SILENT ))
535- netdev_err (bp -> dev , "Resp cmpl intr err msg: 0x%x\n" ,
536- le16_to_cpu (ctx -> req -> req_type ));
565+ hwrm_err (bp , ctx , "Resp cmpl intr err msg: 0x%x\n" ,
566+ req_type );
537567 goto exit ;
538568 }
539569 len = le16_to_cpu (READ_ONCE (ctx -> resp -> resp_len ));
@@ -565,7 +595,7 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
565595 if (resp_seq != seen_out_of_seq ) {
566596 netdev_warn (bp -> dev , "Discarding out of seq response: 0x%x for msg {0x%x 0x%x}\n" ,
567597 le16_to_cpu (resp_seq ),
568- le16_to_cpu ( ctx -> req -> req_type ) ,
598+ req_type ,
569599 le16_to_cpu (ctx -> req -> seq_id ));
570600 seen_out_of_seq = resp_seq ;
571601 }
@@ -585,11 +615,9 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
585615
586616 if (i >= tmo_count ) {
587617timeout_abort :
588- if (!(ctx -> flags & BNXT_HWRM_CTX_SILENT ))
589- netdev_err (bp -> dev , "Error (timeout: %u) msg {0x%x 0x%x} len:%d\n" ,
590- hwrm_total_timeout (i ),
591- le16_to_cpu (ctx -> req -> req_type ),
592- le16_to_cpu (ctx -> req -> seq_id ), len );
618+ hwrm_err (bp , ctx , "Error (timeout: %u) msg {0x%x 0x%x} len:%d\n" ,
619+ hwrm_total_timeout (i ), req_type ,
620+ le16_to_cpu (ctx -> req -> seq_id ), len );
593621 goto exit ;
594622 }
595623
@@ -604,12 +632,9 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
604632 }
605633
606634 if (j >= HWRM_VALID_BIT_DELAY_USEC ) {
607- if (!(ctx -> flags & BNXT_HWRM_CTX_SILENT ))
608- netdev_err (bp -> dev , "Error (timeout: %u) msg {0x%x 0x%x} len:%d v:%d\n" ,
609- hwrm_total_timeout (i ),
610- le16_to_cpu (ctx -> req -> req_type ),
611- le16_to_cpu (ctx -> req -> seq_id ), len ,
612- * valid );
635+ hwrm_err (bp , ctx , "Error (timeout: %u) msg {0x%x 0x%x} len:%d v:%d\n" ,
636+ hwrm_total_timeout (i ), req_type ,
637+ le16_to_cpu (ctx -> req -> seq_id ), len , * valid );
613638 goto exit ;
614639 }
615640 }
@@ -620,11 +645,12 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
620645 */
621646 * valid = 0 ;
622647 rc = le16_to_cpu (ctx -> resp -> error_code );
623- if (rc && !(ctx -> flags & BNXT_HWRM_CTX_SILENT )) {
624- netdev_err (bp -> dev , "hwrm req_type 0x%x seq id 0x%x error 0x%x\n" ,
625- le16_to_cpu (ctx -> resp -> req_type ),
626- le16_to_cpu (ctx -> resp -> seq_id ), rc );
627- }
648+ if (rc == HWRM_ERR_CODE_BUSY && !(ctx -> flags & BNXT_HWRM_CTX_SILENT ))
649+ netdev_warn (bp -> dev , "FW returned busy, hwrm req_type 0x%x\n" ,
650+ req_type );
651+ else if (rc )
652+ hwrm_err (bp , ctx , "hwrm req_type 0x%x seq id 0x%x error 0x%x\n" ,
653+ req_type , token -> seq_id , rc );
628654 rc = __hwrm_to_stderr (rc );
629655exit :
630656 if (token )
0 commit comments