Skip to content

Commit 372c187

Browse files
Dick Kennedymartinkpetersen
authored andcommitted
scsi: lpfc: Add an internal trace log buffer
The current logging methods typically end up requesting a reproduction with a different logging level set to figure out what happened. This was mainly by design to not clutter the kernel log messages with things that were typically not interesting and the messages themselves could cause other issues. When looking to make a better system, it was seen that in many cases when more data was wanted was when another message, usually at KERN_ERR level, was logged. And in most cases, what the additional logging that was then enabled was typically. Most of these areas fell into the discovery machine. Based on this summary, the following design has been put in place: The driver will maintain an internal log (256 elements of 256 bytes). The "additional logging" messages that are usually enabled in a reproduction will be changed to now log all the time to the internal log. A new logging level is defined - LOG_TRACE_EVENT. When this level is set (it is not by default) and a message marked as KERN_ERR is logged, all the messages in the internal log will be dumped to the kernel log before the KERN_ERR message is logged. There is a timestamp on each message added to the internal log. However, this timestamp is not converted to wall time when logged. The value of the timestamp is solely to give a crude time reference for the messages. Link: https://lore.kernel.org/r/20200630215001.70793-14-jsmart2021@gmail.com Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com> Signed-off-by: James Smart <jsmart2021@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 317aeb8 commit 372c187

13 files changed

Lines changed: 928 additions & 792 deletions

‎drivers/scsi/lpfc/lpfc.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,14 @@ struct lpfc_ras_fwlog {
627627
enum ras_state state; /* RAS logging running state */
628628
};
629629

630+
#define DBG_LOG_STR_SZ 256
631+
#define DBG_LOG_SZ 256
632+
633+
struct dbg_log_ent {
634+
char log[DBG_LOG_STR_SZ];
635+
u64 t_ns;
636+
};
637+
630638
enum lpfc_irq_chann_mode {
631639
/* Assign IRQs to all possible cpus that have hardware queues */
632640
NORMAL_MODE,
@@ -1240,6 +1248,10 @@ struct lpfc_hba {
12401248
struct scsi_host_template port_template;
12411249
/* SCSI host template information - for all vports */
12421250
struct scsi_host_template vport_template;
1251+
atomic_t dbg_log_idx;
1252+
atomic_t dbg_log_cnt;
1253+
atomic_t dbg_log_dmping;
1254+
struct dbg_log_ent dbg_log[DBG_LOG_SZ];
12431255
};
12441256

12451257
static inline struct Scsi_Host *

‎drivers/scsi/lpfc/lpfc_crtn.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ void lpfc_rq_buf_free(struct lpfc_hba *phba, struct lpfc_dmabuf *mp);
386386
int lpfc_link_reset(struct lpfc_vport *vport);
387387

388388
/* Function prototypes. */
389-
int lpfc_check_pci_resettable(const struct lpfc_hba *phba);
389+
int lpfc_check_pci_resettable(struct lpfc_hba *phba);
390390
const char* lpfc_info(struct Scsi_Host *);
391391
int lpfc_scan_finished(struct Scsi_Host *, unsigned long);
392392

‎drivers/scsi/lpfc/lpfc_ct.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
750750
if (vport->fc_flag & FC_RSCN_MODE)
751751
lpfc_els_flush_rscn(vport);
752752
lpfc_vport_set_state(vport, FC_VPORT_FAILED);
753-
lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
753+
lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
754754
"0257 GID_FT Query error: 0x%x 0x%x\n",
755755
irsp->ulpStatus, vport->fc_ns_retry);
756756
} else {
@@ -811,7 +811,7 @@ lpfc_cmpl_ct_cmd_gid_ft(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
811811

812812
} else {
813813
/* NameServer Rsp Error */
814-
lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
814+
lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
815815
"0241 NameServer Rsp Error "
816816
"Data: x%x x%x x%x x%x\n",
817817
CTrsp->CommandResponse.bits.CmdRsp,
@@ -951,7 +951,7 @@ lpfc_cmpl_ct_cmd_gid_pt(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
951951
if (vport->fc_flag & FC_RSCN_MODE)
952952
lpfc_els_flush_rscn(vport);
953953
lpfc_vport_set_state(vport, FC_VPORT_FAILED);
954-
lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
954+
lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
955955
"4103 GID_FT Query error: 0x%x 0x%x\n",
956956
irsp->ulpStatus, vport->fc_ns_retry);
957957
} else {
@@ -1012,7 +1012,7 @@ lpfc_cmpl_ct_cmd_gid_pt(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
10121012
}
10131013
} else {
10141014
/* NameServer Rsp Error */
1015-
lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
1015+
lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
10161016
"4109 NameServer Rsp Error "
10171017
"Data: x%x x%x x%x x%x\n",
10181018
CTrsp->CommandResponse.bits.CmdRsp,
@@ -1143,7 +1143,7 @@ lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
11431143
}
11441144
}
11451145
}
1146-
lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
1146+
lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
11471147
"0267 NameServer GFF Rsp "
11481148
"x%x Error (%d %d) Data: x%x x%x\n",
11491149
did, irsp->ulpStatus, irsp->un.ulpWord[4],
@@ -1271,7 +1271,7 @@ lpfc_cmpl_ct_cmd_gft_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
12711271
}
12721272
}
12731273
} else
1274-
lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
1274+
lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
12751275
"3065 GFT_ID failed x%08x\n", irsp->ulpStatus);
12761276

12771277
lpfc_ct_free_iocb(phba, cmdiocb);
@@ -1320,7 +1320,7 @@ lpfc_cmpl_ct(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
13201320
irsp->ulpStatus, irsp->un.ulpWord[4], cmdcode);
13211321

13221322
if (irsp->ulpStatus) {
1323-
lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
1323+
lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
13241324
"0268 NS cmd x%x Error (x%x x%x)\n",
13251325
cmdcode, irsp->ulpStatus, irsp->un.ulpWord[4]);
13261326

@@ -1843,7 +1843,7 @@ lpfc_ns_cmd(struct lpfc_vport *vport, int cmdcode,
18431843
ns_cmd_free_mp:
18441844
kfree(mp);
18451845
ns_cmd_exit:
1846-
lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
1846+
lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
18471847
"0266 Issue NameServer Req x%x err %d Data: x%x x%x\n",
18481848
cmdcode, rc, vport->fc_flag, vport->fc_rscn_id_cnt);
18491849
return 1;

0 commit comments

Comments
 (0)