47
47
#include "lpfc.h"
48
48
#include "lpfc_scsi.h"
49
49
#include "lpfc_nvme.h"
50
+ #include "lpfc_nvmet.h"
50
51
#include "lpfc_logmsg.h"
51
52
#include "lpfc_crtn.h"
52
53
#include "lpfc_vport.h"
@@ -543,11 +544,13 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
543
544
int len = 0 ;
544
545
int cnt ;
545
546
struct Scsi_Host * shost = lpfc_shost_from_vport (vport );
547
+ struct lpfc_hba * phba = vport -> phba ;
546
548
struct lpfc_nodelist * ndlp ;
547
549
unsigned char * statep ;
548
550
struct nvme_fc_local_port * localport ;
549
551
struct lpfc_nvme_lport * lport ;
550
552
struct lpfc_nvme_rport * rport ;
553
+ struct lpfc_nvmet_tgtport * tgtp ;
551
554
struct nvme_fc_remote_port * nrport ;
552
555
553
556
cnt = (LPFC_NODELIST_SIZE / LPFC_NODELIST_ENTRY_SIZE );
@@ -626,6 +629,27 @@ lpfc_debugfs_nodelist_data(struct lpfc_vport *vport, char *buf, int size)
626
629
}
627
630
spin_unlock_irq (shost -> host_lock );
628
631
632
+ if (phba -> nvmet_support && phba -> targetport && (vport == phba -> pport )) {
633
+ tgtp = (struct lpfc_nvmet_tgtport * )phba -> targetport -> private ;
634
+ len += snprintf (buf + len , size - len ,
635
+ "\nNVME Targetport Entry ...\n" );
636
+
637
+ /* Port state is only one of two values for now. */
638
+ if (phba -> targetport -> port_id )
639
+ statep = "REGISTERED" ;
640
+ else
641
+ statep = "INIT" ;
642
+ len += snprintf (buf + len , size - len ,
643
+ "TGT WWNN x%llx WWPN x%llx State %s\n" ,
644
+ wwn_to_u64 (vport -> fc_nodename .u .wwn ),
645
+ wwn_to_u64 (vport -> fc_portname .u .wwn ),
646
+ statep );
647
+ len += snprintf (buf + len , size - len ,
648
+ " Targetport DID x%06x\n" ,
649
+ phba -> targetport -> port_id );
650
+ goto out_exit ;
651
+ }
652
+
629
653
len += snprintf (buf + len , size - len ,
630
654
"\nNVME Lport/Rport Entries ...\n" );
631
655
@@ -718,9 +742,75 @@ static int
718
742
lpfc_debugfs_nvmestat_data (struct lpfc_vport * vport , char * buf , int size )
719
743
{
720
744
struct lpfc_hba * phba = vport -> phba ;
745
+ struct lpfc_nvmet_tgtport * tgtp ;
721
746
int len = 0 ;
722
747
723
- if (phba -> nvmet_support == 0 ) {
748
+ if (phba -> nvmet_support ) {
749
+ if (!phba -> targetport )
750
+ return len ;
751
+ tgtp = (struct lpfc_nvmet_tgtport * )phba -> targetport -> private ;
752
+ len += snprintf (buf + len , size - len ,
753
+ "\nNVME Targetport Statistics\n" );
754
+
755
+ len += snprintf (buf + len , size - len ,
756
+ "LS: Rcv %08x Drop %08x Abort %08x\n" ,
757
+ atomic_read (& tgtp -> rcv_ls_req_in ),
758
+ atomic_read (& tgtp -> rcv_ls_req_drop ),
759
+ atomic_read (& tgtp -> xmt_ls_abort ));
760
+ if (atomic_read (& tgtp -> rcv_ls_req_in ) !=
761
+ atomic_read (& tgtp -> rcv_ls_req_out )) {
762
+ len += snprintf (buf + len , size - len ,
763
+ "Rcv LS: in %08x != out %08x\n" ,
764
+ atomic_read (& tgtp -> rcv_ls_req_in ),
765
+ atomic_read (& tgtp -> rcv_ls_req_out ));
766
+ }
767
+
768
+ len += snprintf (buf + len , size - len ,
769
+ "LS: Xmt %08x Drop %08x Cmpl %08x Err %08x\n" ,
770
+ atomic_read (& tgtp -> xmt_ls_rsp ),
771
+ atomic_read (& tgtp -> xmt_ls_drop ),
772
+ atomic_read (& tgtp -> xmt_ls_rsp_cmpl ),
773
+ atomic_read (& tgtp -> xmt_ls_rsp_error ));
774
+
775
+ len += snprintf (buf + len , size - len ,
776
+ "FCP: Rcv %08x Drop %08x\n" ,
777
+ atomic_read (& tgtp -> rcv_fcp_cmd_in ),
778
+ atomic_read (& tgtp -> rcv_fcp_cmd_drop ));
779
+
780
+ if (atomic_read (& tgtp -> rcv_fcp_cmd_in ) !=
781
+ atomic_read (& tgtp -> rcv_fcp_cmd_out )) {
782
+ len += snprintf (buf + len , size - len ,
783
+ "Rcv FCP: in %08x != out %08x\n" ,
784
+ atomic_read (& tgtp -> rcv_fcp_cmd_in ),
785
+ atomic_read (& tgtp -> rcv_fcp_cmd_out ));
786
+ }
787
+
788
+ len += snprintf (buf + len , size - len ,
789
+ "FCP Rsp: read %08x readrsp %08x write %08x rsp %08x\n" ,
790
+ atomic_read (& tgtp -> xmt_fcp_read ),
791
+ atomic_read (& tgtp -> xmt_fcp_read_rsp ),
792
+ atomic_read (& tgtp -> xmt_fcp_write ),
793
+ atomic_read (& tgtp -> xmt_fcp_rsp ));
794
+
795
+ len += snprintf (buf + len , size - len ,
796
+ "FCP Rsp: abort %08x drop %08x\n" ,
797
+ atomic_read (& tgtp -> xmt_fcp_abort ),
798
+ atomic_read (& tgtp -> xmt_fcp_drop ));
799
+
800
+ len += snprintf (buf + len , size - len ,
801
+ "FCP Rsp Cmpl: %08x err %08x drop %08x\n" ,
802
+ atomic_read (& tgtp -> xmt_fcp_rsp_cmpl ),
803
+ atomic_read (& tgtp -> xmt_fcp_rsp_error ),
804
+ atomic_read (& tgtp -> xmt_fcp_rsp_drop ));
805
+
806
+ len += snprintf (buf + len , size - len ,
807
+ "ABORT: Xmt %08x Err %08x Cmpl %08x" ,
808
+ atomic_read (& tgtp -> xmt_abort_rsp ),
809
+ atomic_read (& tgtp -> xmt_abort_rsp_error ),
810
+ atomic_read (& tgtp -> xmt_abort_cmpl ));
811
+
812
+ len += snprintf (buf + len , size - len , "\n" );
813
+ } else {
724
814
if (!(phba -> cfg_enable_fc4_type & LPFC_ENABLE_NVME ))
725
815
return len ;
726
816
@@ -828,6 +918,121 @@ lpfc_debugfs_nvmektime_data(struct lpfc_vport *vport, char *buf, int size)
828
918
phba -> ktime_data_samples ));
829
919
return len ;
830
920
}
921
+
922
+ /* NVME Target */
923
+ len += snprintf (buf + len , PAGE_SIZE - len ,
924
+ "ktime %s: Total Samples: %lld %lld\n" ,
925
+ (phba -> ktime_on ? "Enabled" : "Disabled" ),
926
+ phba -> ktime_data_samples ,
927
+ phba -> ktime_status_samples );
928
+ if (phba -> ktime_data_samples == 0 )
929
+ return len ;
930
+
931
+ len += snprintf (buf + len , PAGE_SIZE - len ,
932
+ "Segment 1: MSI-X ISR Rcv cmd -to- "
933
+ "cmd pass to NVME Layer\n" );
934
+ len += snprintf (buf + len , PAGE_SIZE - len ,
935
+ "avg:%08lld min:%08lld max %08lld\n" ,
936
+ phba -> ktime_seg1_total /
937
+ phba -> ktime_data_samples ,
938
+ phba -> ktime_seg1_min ,
939
+ phba -> ktime_seg1_max );
940
+ len += snprintf (buf + len , PAGE_SIZE - len ,
941
+ "Segment 2: cmd pass to NVME Layer- "
942
+ "-to- Driver rcv cmd OP (action)\n" );
943
+ len += snprintf (buf + len , PAGE_SIZE - len ,
944
+ "avg:%08lld min:%08lld max %08lld\n" ,
945
+ phba -> ktime_seg2_total /
946
+ phba -> ktime_data_samples ,
947
+ phba -> ktime_seg2_min ,
948
+ phba -> ktime_seg2_max );
949
+ len += snprintf (buf + len , PAGE_SIZE - len ,
950
+ "Segment 3: Driver rcv cmd OP -to- "
951
+ "Firmware WQ doorbell: cmd\n" );
952
+ len += snprintf (buf + len , PAGE_SIZE - len ,
953
+ "avg:%08lld min:%08lld max %08lld\n" ,
954
+ phba -> ktime_seg3_total /
955
+ phba -> ktime_data_samples ,
956
+ phba -> ktime_seg3_min ,
957
+ phba -> ktime_seg3_max );
958
+ len += snprintf (buf + len , PAGE_SIZE - len ,
959
+ "Segment 4: Firmware WQ doorbell: cmd "
960
+ "-to- MSI-X ISR for cmd cmpl\n" );
961
+ len += snprintf (buf + len , PAGE_SIZE - len ,
962
+ "avg:%08lld min:%08lld max %08lld\n" ,
963
+ phba -> ktime_seg4_total /
964
+ phba -> ktime_data_samples ,
965
+ phba -> ktime_seg4_min ,
966
+ phba -> ktime_seg4_max );
967
+ len += snprintf (buf + len , PAGE_SIZE - len ,
968
+ "Segment 5: MSI-X ISR for cmd cmpl "
969
+ "-to- NVME layer passed cmd done\n" );
970
+ len += snprintf (buf + len , PAGE_SIZE - len ,
971
+ "avg:%08lld min:%08lld max %08lld\n" ,
972
+ phba -> ktime_seg5_total /
973
+ phba -> ktime_data_samples ,
974
+ phba -> ktime_seg5_min ,
975
+ phba -> ktime_seg5_max );
976
+
977
+ if (phba -> ktime_status_samples == 0 ) {
978
+ len += snprintf (buf + len , PAGE_SIZE - len ,
979
+ "Total: cmd received by MSI-X ISR "
980
+ "-to- cmd completed on wire\n" );
981
+ len += snprintf (buf + len , PAGE_SIZE - len ,
982
+ "avg:%08lld min:%08lld "
983
+ "max %08lld\n" ,
984
+ phba -> ktime_seg10_total /
985
+ phba -> ktime_data_samples ,
986
+ phba -> ktime_seg10_min ,
987
+ phba -> ktime_seg10_max );
988
+ return len ;
989
+ }
990
+
991
+ len += snprintf (buf + len , PAGE_SIZE - len ,
992
+ "Segment 6: NVME layer passed cmd done "
993
+ "-to- Driver rcv rsp status OP\n" );
994
+ len += snprintf (buf + len , PAGE_SIZE - len ,
995
+ "avg:%08lld min:%08lld max %08lld\n" ,
996
+ phba -> ktime_seg6_total /
997
+ phba -> ktime_status_samples ,
998
+ phba -> ktime_seg6_min ,
999
+ phba -> ktime_seg6_max );
1000
+ len += snprintf (buf + len , PAGE_SIZE - len ,
1001
+ "Segment 7: Driver rcv rsp status OP "
1002
+ "-to- Firmware WQ doorbell: status\n" );
1003
+ len += snprintf (buf + len , PAGE_SIZE - len ,
1004
+ "avg:%08lld min:%08lld max %08lld\n" ,
1005
+ phba -> ktime_seg7_total /
1006
+ phba -> ktime_status_samples ,
1007
+ phba -> ktime_seg7_min ,
1008
+ phba -> ktime_seg7_max );
1009
+ len += snprintf (buf + len , PAGE_SIZE - len ,
1010
+ "Segment 8: Firmware WQ doorbell: status"
1011
+ " -to- MSI-X ISR for status cmpl\n" );
1012
+ len += snprintf (buf + len , PAGE_SIZE - len ,
1013
+ "avg:%08lld min:%08lld max %08lld\n" ,
1014
+ phba -> ktime_seg8_total /
1015
+ phba -> ktime_status_samples ,
1016
+ phba -> ktime_seg8_min ,
1017
+ phba -> ktime_seg8_max );
1018
+ len += snprintf (buf + len , PAGE_SIZE - len ,
1019
+ "Segment 9: MSI-X ISR for status cmpl "
1020
+ "-to- NVME layer passed status done\n" );
1021
+ len += snprintf (buf + len , PAGE_SIZE - len ,
1022
+ "avg:%08lld min:%08lld max %08lld\n" ,
1023
+ phba -> ktime_seg9_total /
1024
+ phba -> ktime_status_samples ,
1025
+ phba -> ktime_seg9_min ,
1026
+ phba -> ktime_seg9_max );
1027
+ len += snprintf (buf + len , PAGE_SIZE - len ,
1028
+ "Total: cmd received by MSI-X ISR -to- "
1029
+ "cmd completed on wire\n" );
1030
+ len += snprintf (buf + len , PAGE_SIZE - len ,
1031
+ "avg:%08lld min:%08lld max %08lld\n" ,
1032
+ phba -> ktime_seg10_total /
1033
+ phba -> ktime_status_samples ,
1034
+ phba -> ktime_seg10_min ,
1035
+ phba -> ktime_seg10_max );
831
1036
return len ;
832
1037
}
833
1038
@@ -953,7 +1158,9 @@ lpfc_debugfs_cpucheck_data(struct lpfc_vport *vport, char *buf, int size)
953
1158
int i ;
954
1159
int len = 0 ;
955
1160
uint32_t tot_xmt = 0 ;
1161
+ uint32_t tot_rcv = 0 ;
956
1162
uint32_t tot_cmpl = 0 ;
1163
+ uint32_t tot_ccmpl = 0 ;
957
1164
958
1165
if (phba -> nvmet_support == 0 ) {
959
1166
/* NVME Initiator */
@@ -977,6 +1184,33 @@ lpfc_debugfs_cpucheck_data(struct lpfc_vport *vport, char *buf, int size)
977
1184
return len ;
978
1185
}
979
1186
1187
+ /* NVME Target */
1188
+ len += snprintf (buf + len , PAGE_SIZE - len ,
1189
+ "CPUcheck %s " ,
1190
+ (phba -> cpucheck_on & LPFC_CHECK_NVMET_IO ?
1191
+ "IO Enabled - " : "IO Disabled - " ));
1192
+ len += snprintf (buf + len , PAGE_SIZE - len ,
1193
+ "%s\n" ,
1194
+ (phba -> cpucheck_on & LPFC_CHECK_NVMET_RCV ?
1195
+ "Rcv Enabled\n" : "Rcv Disabled\n" ));
1196
+ for (i = 0 ; i < phba -> sli4_hba .num_present_cpu ; i ++ ) {
1197
+ if (i >= LPFC_CHECK_CPU_CNT )
1198
+ break ;
1199
+ len += snprintf (buf + len , PAGE_SIZE - len ,
1200
+ "%02d: xmit x%08x ccmpl x%08x "
1201
+ "cmpl x%08x rcv x%08x\n" ,
1202
+ i , phba -> cpucheck_xmt_io [i ],
1203
+ phba -> cpucheck_ccmpl_io [i ],
1204
+ phba -> cpucheck_cmpl_io [i ],
1205
+ phba -> cpucheck_rcv_io [i ]);
1206
+ tot_xmt += phba -> cpucheck_xmt_io [i ];
1207
+ tot_rcv += phba -> cpucheck_rcv_io [i ];
1208
+ tot_cmpl += phba -> cpucheck_cmpl_io [i ];
1209
+ tot_ccmpl += phba -> cpucheck_ccmpl_io [i ];
1210
+ }
1211
+ len += snprintf (buf + len , PAGE_SIZE - len ,
1212
+ "tot:xmit x%08x ccmpl x%08x cmpl x%08x rcv x%08x\n" ,
1213
+ tot_xmt , tot_ccmpl , tot_cmpl , tot_rcv );
980
1214
return len ;
981
1215
}
982
1216
@@ -1660,6 +1894,65 @@ lpfc_debugfs_nvmestat_open(struct inode *inode, struct file *file)
1660
1894
return rc ;
1661
1895
}
1662
1896
1897
+ static ssize_t
1898
+ lpfc_debugfs_nvmestat_write (struct file * file , const char __user * buf ,
1899
+ size_t nbytes , loff_t * ppos )
1900
+ {
1901
+ struct lpfc_debug * debug = file -> private_data ;
1902
+ struct lpfc_vport * vport = (struct lpfc_vport * )debug -> i_private ;
1903
+ struct lpfc_hba * phba = vport -> phba ;
1904
+ struct lpfc_nvmet_tgtport * tgtp ;
1905
+ char mybuf [64 ];
1906
+ char * pbuf ;
1907
+
1908
+ if (!phba -> targetport )
1909
+ return - ENXIO ;
1910
+
1911
+ if (nbytes > 64 )
1912
+ nbytes = 64 ;
1913
+
1914
+ /* Protect copy from user */
1915
+ if (!access_ok (VERIFY_READ , buf , nbytes ))
1916
+ return - EFAULT ;
1917
+
1918
+ memset (mybuf , 0 , sizeof (mybuf ));
1919
+
1920
+ if (copy_from_user (mybuf , buf , nbytes ))
1921
+ return - EFAULT ;
1922
+ pbuf = & mybuf [0 ];
1923
+
1924
+ tgtp = (struct lpfc_nvmet_tgtport * )phba -> targetport -> private ;
1925
+ if ((strncmp (pbuf , "reset" , strlen ("reset" )) == 0 ) ||
1926
+ (strncmp (pbuf , "zero" , strlen ("zero" )) == 0 )) {
1927
+ atomic_set (& tgtp -> rcv_ls_req_in , 0 );
1928
+ atomic_set (& tgtp -> rcv_ls_req_out , 0 );
1929
+ atomic_set (& tgtp -> rcv_ls_req_drop , 0 );
1930
+ atomic_set (& tgtp -> xmt_ls_abort , 0 );
1931
+ atomic_set (& tgtp -> xmt_ls_rsp , 0 );
1932
+ atomic_set (& tgtp -> xmt_ls_drop , 0 );
1933
+ atomic_set (& tgtp -> xmt_ls_rsp_error , 0 );
1934
+ atomic_set (& tgtp -> xmt_ls_rsp_cmpl , 0 );
1935
+
1936
+ atomic_set (& tgtp -> rcv_fcp_cmd_in , 0 );
1937
+ atomic_set (& tgtp -> rcv_fcp_cmd_out , 0 );
1938
+ atomic_set (& tgtp -> rcv_fcp_cmd_drop , 0 );
1939
+ atomic_set (& tgtp -> xmt_fcp_abort , 0 );
1940
+ atomic_set (& tgtp -> xmt_fcp_drop , 0 );
1941
+ atomic_set (& tgtp -> xmt_fcp_read_rsp , 0 );
1942
+ atomic_set (& tgtp -> xmt_fcp_read , 0 );
1943
+ atomic_set (& tgtp -> xmt_fcp_write , 0 );
1944
+ atomic_set (& tgtp -> xmt_fcp_rsp , 0 );
1945
+ atomic_set (& tgtp -> xmt_fcp_rsp_cmpl , 0 );
1946
+ atomic_set (& tgtp -> xmt_fcp_rsp_error , 0 );
1947
+ atomic_set (& tgtp -> xmt_fcp_rsp_drop , 0 );
1948
+
1949
+ atomic_set (& tgtp -> xmt_abort_rsp , 0 );
1950
+ atomic_set (& tgtp -> xmt_abort_rsp_error , 0 );
1951
+ atomic_set (& tgtp -> xmt_abort_cmpl , 0 );
1952
+ }
1953
+ return nbytes ;
1954
+ }
1955
+
1663
1956
static int
1664
1957
lpfc_debugfs_nvmektime_open (struct inode * inode , struct file * file )
1665
1958
{
@@ -1956,7 +2249,10 @@ lpfc_debugfs_cpucheck_write(struct file *file, const char __user *buf,
1956
2249
pbuf = & mybuf [0 ];
1957
2250
1958
2251
if ((strncmp (pbuf , "on" , sizeof ("on" ) - 1 ) == 0 )) {
1959
- phba -> cpucheck_on |= LPFC_CHECK_NVME_IO ;
2252
+ if (phba -> nvmet_support )
2253
+ phba -> cpucheck_on |= LPFC_CHECK_NVMET_IO ;
2254
+ else
2255
+ phba -> cpucheck_on |= LPFC_CHECK_NVME_IO ;
1960
2256
return strlen (pbuf );
1961
2257
} else if ((strncmp (pbuf , "rcv" ,
1962
2258
sizeof ("rcv" ) - 1 ) == 0 )) {
@@ -2880,7 +3176,7 @@ lpfc_idiag_cqs_for_eq(struct lpfc_hba *phba, char *pbuffer,
2880
3176
return 1 ;
2881
3177
}
2882
3178
2883
- if (phba -> cfg_nvmet_mrq > eqidx ) {
3179
+ if (eqidx < phba -> cfg_nvmet_mrq ) {
2884
3180
/* NVMET CQset */
2885
3181
qp = phba -> sli4_hba .nvmet_cqset [eqidx ];
2886
3182
* len = __lpfc_idiag_print_cq (qp , "NVMET CQset" , pbuffer , * len );
@@ -4493,6 +4789,7 @@ static const struct file_operations lpfc_debugfs_op_nvmestat = {
4493
4789
.open = lpfc_debugfs_nvmestat_open ,
4494
4790
.llseek = lpfc_debugfs_lseek ,
4495
4791
.read = lpfc_debugfs_read ,
4792
+ .write = lpfc_debugfs_nvmestat_write ,
4496
4793
.release = lpfc_debugfs_release ,
4497
4794
};
4498
4795
0 commit comments