@@ -840,7 +840,7 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
840
840
struct lpfc_nvmet_tgtport * tgtp ;
841
841
struct lpfc_nvmet_rcv_ctx * ctxp , * next_ctxp ;
842
842
struct nvme_fc_local_port * localport ;
843
- struct lpfc_nvme_ctrl_stat * cstat ;
843
+ struct lpfc_fc4_ctrl_stat * cstat ;
844
844
struct lpfc_nvme_lport * lport ;
845
845
uint64_t data1 , data2 , data3 ;
846
846
uint64_t tot , totin , totout ;
@@ -979,7 +979,7 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
979
979
return len ;
980
980
981
981
len += snprintf (buf + len , size - len ,
982
- "\nNVME Lport Statistics\n" );
982
+ "\nNVME HDWQ Statistics\n" );
983
983
984
984
len += snprintf (buf + len , size - len ,
985
985
"LS: Xmt %016x Cmpl %016x\n" ,
@@ -993,20 +993,20 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
993
993
totin = 0 ;
994
994
totout = 0 ;
995
995
for (i = 0 ; i < phba -> cfg_hdw_queue ; i ++ ) {
996
- cstat = & lport -> cstat [i ];
997
- tot = atomic_read ( & cstat -> fc4NvmeIoCmpls ) ;
996
+ cstat = & phba -> sli4_hba . hdwq [i ]. nvme_cstat ;
997
+ tot = cstat -> io_cmpls ;
998
998
totin += tot ;
999
- data1 = atomic_read ( & cstat -> fc4NvmeInputRequests ) ;
1000
- data2 = atomic_read ( & cstat -> fc4NvmeOutputRequests ) ;
1001
- data3 = atomic_read ( & cstat -> fc4NvmeControlRequests ) ;
999
+ data1 = cstat -> input_requests ;
1000
+ data2 = cstat -> output_requests ;
1001
+ data3 = cstat -> control_requests ;
1002
1002
totout += (data1 + data2 + data3 );
1003
1003
1004
1004
/* Limit to 32, debugfs display buffer limitation */
1005
1005
if (i >= 32 )
1006
1006
continue ;
1007
1007
1008
1008
len += snprintf (buf + len , PAGE_SIZE - len ,
1009
- "FCP (%d): Rd %016llx Wr %016llx "
1009
+ "HDWQ (%d): Rd %016llx Wr %016llx "
1010
1010
"IO %016llx " ,
1011
1011
i , data1 , data2 , data3 );
1012
1012
len += snprintf (buf + len , PAGE_SIZE - len ,
@@ -1046,6 +1046,66 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, char *buf, int size)
1046
1046
return len ;
1047
1047
}
1048
1048
1049
+ /**
1050
+ * lpfc_debugfs_scsistat_data - Dump target node list to a buffer
1051
+ * @vport: The vport to gather target node info from.
1052
+ * @buf: The buffer to dump log into.
1053
+ * @size: The maximum amount of data to process.
1054
+ *
1055
+ * Description:
1056
+ * This routine dumps the SCSI statistics associated with @vport
1057
+ *
1058
+ * Return Value:
1059
+ * This routine returns the amount of bytes that were dumped into @buf and will
1060
+ * not exceed @size.
1061
+ **/
1062
+ static int
1063
+ lpfc_debugfs_scsistat_data (struct lpfc_vport * vport , char * buf , int size )
1064
+ {
1065
+ int len ;
1066
+ struct lpfc_hba * phba = vport -> phba ;
1067
+ struct lpfc_fc4_ctrl_stat * cstat ;
1068
+ u64 data1 , data2 , data3 ;
1069
+ u64 tot , totin , totout ;
1070
+ int i ;
1071
+ char tmp [LPFC_MAX_SCSI_INFO_TMP_LEN ] = {0 };
1072
+
1073
+ if (!(phba -> cfg_enable_fc4_type & LPFC_ENABLE_FCP ) ||
1074
+ (phba -> sli_rev != LPFC_SLI_REV4 ))
1075
+ return 0 ;
1076
+
1077
+ scnprintf (buf , size , "SCSI HDWQ Statistics\n" );
1078
+
1079
+ totin = 0 ;
1080
+ totout = 0 ;
1081
+ for (i = 0 ; i < phba -> cfg_hdw_queue ; i ++ ) {
1082
+ cstat = & phba -> sli4_hba .hdwq [i ].scsi_cstat ;
1083
+ tot = cstat -> io_cmpls ;
1084
+ totin += tot ;
1085
+ data1 = cstat -> input_requests ;
1086
+ data2 = cstat -> output_requests ;
1087
+ data3 = cstat -> control_requests ;
1088
+ totout += (data1 + data2 + data3 );
1089
+
1090
+ scnprintf (tmp , sizeof (tmp ), "HDWQ (%d): Rd %016llx Wr %016llx "
1091
+ "IO %016llx " , i , data1 , data2 , data3 );
1092
+ if (strlcat (buf , tmp , size ) >= size )
1093
+ goto buffer_done ;
1094
+
1095
+ scnprintf (tmp , sizeof (tmp ), "Cmpl %016llx OutIO %016llx\n" ,
1096
+ tot , ((data1 + data2 + data3 ) - tot ));
1097
+ if (strlcat (buf , tmp , size ) >= size )
1098
+ goto buffer_done ;
1099
+ }
1100
+ scnprintf (tmp , sizeof (tmp ), "Total FCP Cmpl %016llx Issue %016llx "
1101
+ "OutIO %016llx\n" , totin , totout , totout - totin );
1102
+ strlcat (buf , tmp , size );
1103
+
1104
+ buffer_done :
1105
+ len = strnlen (buf , size );
1106
+
1107
+ return len ;
1108
+ }
1049
1109
1050
1110
/**
1051
1111
* lpfc_debugfs_nvmektime_data - Dump target node list to a buffer
@@ -2211,6 +2271,64 @@ lpfc_debugfs_nvmestat_write(struct file *file, const char __user *buf,
2211
2271
return nbytes ;
2212
2272
}
2213
2273
2274
+ static int
2275
+ lpfc_debugfs_scsistat_open (struct inode * inode , struct file * file )
2276
+ {
2277
+ struct lpfc_vport * vport = inode -> i_private ;
2278
+ struct lpfc_debug * debug ;
2279
+ int rc = - ENOMEM ;
2280
+
2281
+ debug = kmalloc (sizeof (* debug ), GFP_KERNEL );
2282
+ if (!debug )
2283
+ goto out ;
2284
+
2285
+ /* Round to page boundary */
2286
+ debug -> buffer = kzalloc (LPFC_SCSISTAT_SIZE , GFP_KERNEL );
2287
+ if (!debug -> buffer ) {
2288
+ kfree (debug );
2289
+ goto out ;
2290
+ }
2291
+
2292
+ debug -> len = lpfc_debugfs_scsistat_data (vport , debug -> buffer ,
2293
+ LPFC_SCSISTAT_SIZE );
2294
+
2295
+ debug -> i_private = inode -> i_private ;
2296
+ file -> private_data = debug ;
2297
+
2298
+ rc = 0 ;
2299
+ out :
2300
+ return rc ;
2301
+ }
2302
+
2303
+ static ssize_t
2304
+ lpfc_debugfs_scsistat_write (struct file * file , const char __user * buf ,
2305
+ size_t nbytes , loff_t * ppos )
2306
+ {
2307
+ struct lpfc_debug * debug = file -> private_data ;
2308
+ struct lpfc_vport * vport = (struct lpfc_vport * )debug -> i_private ;
2309
+ struct lpfc_hba * phba = vport -> phba ;
2310
+ char mybuf [6 ] = {0 };
2311
+ int i ;
2312
+
2313
+ /* Protect copy from user */
2314
+ if (!access_ok (buf , nbytes ))
2315
+ return - EFAULT ;
2316
+
2317
+ if (copy_from_user (mybuf , buf , (nbytes >= sizeof (mybuf )) ?
2318
+ (sizeof (mybuf ) - 1 ) : nbytes ))
2319
+ return - EFAULT ;
2320
+
2321
+ if ((strncmp (& mybuf [0 ], "reset" , strlen ("reset" )) == 0 ) ||
2322
+ (strncmp (& mybuf [0 ], "zero" , strlen ("zero" )) == 0 )) {
2323
+ for (i = 0 ; i < phba -> cfg_hdw_queue ; i ++ ) {
2324
+ memset (& phba -> sli4_hba .hdwq [i ].scsi_cstat , 0 ,
2325
+ sizeof (phba -> sli4_hba .hdwq [i ].scsi_cstat ));
2326
+ }
2327
+ }
2328
+
2329
+ return nbytes ;
2330
+ }
2331
+
2214
2332
static int
2215
2333
lpfc_debugfs_nvmektime_open (struct inode * inode , struct file * file )
2216
2334
{
@@ -4972,6 +5090,16 @@ static const struct file_operations lpfc_debugfs_op_nvmestat = {
4972
5090
.release = lpfc_debugfs_release ,
4973
5091
};
4974
5092
5093
+ #undef lpfc_debugfs_op_scsistat
5094
+ static const struct file_operations lpfc_debugfs_op_scsistat = {
5095
+ .owner = THIS_MODULE ,
5096
+ .open = lpfc_debugfs_scsistat_open ,
5097
+ .llseek = lpfc_debugfs_lseek ,
5098
+ .read = lpfc_debugfs_read ,
5099
+ .write = lpfc_debugfs_scsistat_write ,
5100
+ .release = lpfc_debugfs_release ,
5101
+ };
5102
+
4975
5103
#undef lpfc_debugfs_op_nvmektime
4976
5104
static const struct file_operations lpfc_debugfs_op_nvmektime = {
4977
5105
.owner = THIS_MODULE ,
@@ -5612,6 +5740,17 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
5612
5740
vport -> vport_debugfs_root ,
5613
5741
vport , & lpfc_debugfs_op_nvmestat );
5614
5742
5743
+ snprintf (name , sizeof (name ), "scsistat" );
5744
+ vport -> debug_scsistat =
5745
+ debugfs_create_file (name , 0644 ,
5746
+ vport -> vport_debugfs_root ,
5747
+ vport , & lpfc_debugfs_op_scsistat );
5748
+ if (!vport -> debug_scsistat ) {
5749
+ lpfc_printf_vlog (vport , KERN_ERR , LOG_INIT ,
5750
+ "0811 Cannot create debugfs scsistat\n" );
5751
+ goto debug_failed ;
5752
+ }
5753
+
5615
5754
snprintf (name , sizeof (name ), "nvmektime" );
5616
5755
vport -> debug_nvmektime =
5617
5756
debugfs_create_file (name , 0644 ,
@@ -5750,6 +5889,9 @@ lpfc_debugfs_terminate(struct lpfc_vport *vport)
5750
5889
debugfs_remove (vport -> debug_nvmestat ); /* nvmestat */
5751
5890
vport -> debug_nvmestat = NULL ;
5752
5891
5892
+ debugfs_remove (vport -> debug_scsistat ); /* scsistat */
5893
+ vport -> debug_scsistat = NULL ;
5894
+
5753
5895
debugfs_remove (vport -> debug_nvmektime ); /* nvmektime */
5754
5896
vport -> debug_nvmektime = NULL ;
5755
5897
0 commit comments