@@ -2078,6 +2078,96 @@ lpfc_debugfs_lockstat_write(struct file *file, const char __user *buf,
20782078}
20792079#endif
20802080
2081+ int
2082+ lpfc_debugfs_ras_log_data (struct lpfc_hba * phba , char * buffer , int size )
2083+ {
2084+ int copied = 0 ;
2085+ struct lpfc_dmabuf * dmabuf , * next ;
2086+
2087+ spin_lock_irq (& phba -> hbalock );
2088+ if (phba -> ras_fwlog .state != ACTIVE ) {
2089+ spin_unlock_irq (& phba -> hbalock );
2090+ return - EINVAL ;
2091+ }
2092+ spin_unlock_irq (& phba -> hbalock );
2093+
2094+ list_for_each_entry_safe (dmabuf , next ,
2095+ & phba -> ras_fwlog .fwlog_buff_list , list ) {
2096+ memcpy (buffer + copied , dmabuf -> virt , LPFC_RAS_MAX_ENTRY_SIZE );
2097+ copied += LPFC_RAS_MAX_ENTRY_SIZE ;
2098+ if (size > copied )
2099+ break ;
2100+ }
2101+ return copied ;
2102+ }
2103+
2104+ static int
2105+ lpfc_debugfs_ras_log_release (struct inode * inode , struct file * file )
2106+ {
2107+ struct lpfc_debug * debug = file -> private_data ;
2108+
2109+ vfree (debug -> buffer );
2110+ kfree (debug );
2111+
2112+ return 0 ;
2113+ }
2114+
2115+ /**
2116+ * lpfc_debugfs_ras_log_open - Open the RAS log debugfs buffer
2117+ * @inode: The inode pointer that contains a vport pointer.
2118+ * @file: The file pointer to attach the log output.
2119+ *
2120+ * Description:
2121+ * This routine is the entry point for the debugfs open file operation. It gets
2122+ * the vport from the i_private field in @inode, allocates the necessary buffer
2123+ * for the log, fills the buffer from the in-memory log for this vport, and then
2124+ * returns a pointer to that log in the private_data field in @file.
2125+ *
2126+ * Returns:
2127+ * This function returns zero if successful. On error it will return a negative
2128+ * error value.
2129+ **/
2130+ static int
2131+ lpfc_debugfs_ras_log_open (struct inode * inode , struct file * file )
2132+ {
2133+ struct lpfc_hba * phba = inode -> i_private ;
2134+ struct lpfc_debug * debug ;
2135+ int size ;
2136+ int rc = - ENOMEM ;
2137+
2138+ spin_lock_irq (& phba -> hbalock );
2139+ if (phba -> ras_fwlog .state != ACTIVE ) {
2140+ spin_unlock_irq (& phba -> hbalock );
2141+ rc = - EINVAL ;
2142+ goto out ;
2143+ }
2144+ spin_unlock_irq (& phba -> hbalock );
2145+ debug = kmalloc (sizeof (* debug ), GFP_KERNEL );
2146+ if (!debug )
2147+ goto out ;
2148+
2149+ size = LPFC_RAS_MIN_BUFF_POST_SIZE * phba -> cfg_ras_fwlog_buffsize ;
2150+ debug -> buffer = vmalloc (size );
2151+ if (!debug -> buffer )
2152+ goto free_debug ;
2153+
2154+ debug -> len = lpfc_debugfs_ras_log_data (phba , debug -> buffer , size );
2155+ if (debug -> len < 0 ) {
2156+ rc = - EINVAL ;
2157+ goto free_buffer ;
2158+ }
2159+ file -> private_data = debug ;
2160+
2161+ return 0 ;
2162+
2163+ free_buffer :
2164+ vfree (debug -> buffer );
2165+ free_debug :
2166+ kfree (debug );
2167+ out :
2168+ return rc ;
2169+ }
2170+
20812171/**
20822172 * lpfc_debugfs_dumpHBASlim_open - Open the Dump HBA SLIM debugfs buffer
20832173 * @inode: The inode pointer that contains a vport pointer.
@@ -5286,6 +5376,16 @@ static const struct file_operations lpfc_debugfs_op_lockstat = {
52865376};
52875377#endif
52885378
5379+ #undef lpfc_debugfs_ras_log
5380+ static const struct file_operations lpfc_debugfs_ras_log = {
5381+ .owner = THIS_MODULE ,
5382+ .open = lpfc_debugfs_ras_log_open ,
5383+ .llseek = lpfc_debugfs_lseek ,
5384+ .read = lpfc_debugfs_read ,
5385+ .release = lpfc_debugfs_ras_log_release ,
5386+ };
5387+ #endif
5388+
52895389#undef lpfc_debugfs_op_dumpHBASlim
52905390static const struct file_operations lpfc_debugfs_op_dumpHBASlim = {
52915391 .owner = THIS_MODULE ,
@@ -5457,7 +5557,6 @@ static const struct file_operations lpfc_idiag_op_extAcc = {
54575557 .release = lpfc_idiag_cmd_release ,
54585558};
54595559
5460- #endif
54615560
54625561/* lpfc_idiag_mbxacc_dump_bsg_mbox - idiag debugfs dump bsg mailbox command
54635562 * @phba: Pointer to HBA context object.
@@ -5707,6 +5806,19 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
57075806 goto debug_failed ;
57085807 }
57095808
5809+ /* RAS log */
5810+ snprintf (name , sizeof (name ), "ras_log" );
5811+ phba -> debug_ras_log =
5812+ debugfs_create_file (name , 0644 ,
5813+ phba -> hba_debugfs_root ,
5814+ phba , & lpfc_debugfs_ras_log );
5815+ if (!phba -> debug_ras_log ) {
5816+ lpfc_printf_vlog (vport , KERN_ERR , LOG_INIT ,
5817+ "6148 Cannot create debugfs"
5818+ " ras_log\n" );
5819+ goto debug_failed ;
5820+ }
5821+
57105822 /* Setup hbqinfo */
57115823 snprintf (name , sizeof (name ), "hbqinfo" );
57125824 phba -> debug_hbqinfo =
@@ -6117,6 +6229,9 @@ lpfc_debugfs_terminate(struct lpfc_vport *vport)
61176229 debugfs_remove (phba -> debug_hbqinfo ); /* hbqinfo */
61186230 phba -> debug_hbqinfo = NULL ;
61196231
6232+ debugfs_remove (phba -> debug_ras_log );
6233+ phba -> debug_ras_log = NULL ;
6234+
61206235#ifdef LPFC_HDWQ_LOCK_STAT
61216236 debugfs_remove (phba -> debug_lockstat ); /* lockstat */
61226237 phba -> debug_lockstat = NULL ;
0 commit comments