forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/scsi/lpfc/lpfc_ct.c
....@@ -1,7 +1,7 @@
11 /*******************************************************************
22 * This file is part of the Emulex Linux Device Driver for *
33 * Fibre Channel Host Bus Adapters. *
4
- * Copyright (C) 2017-2018 Broadcom. All Rights Reserved. The term *
4
+ * Copyright (C) 2017-2020 Broadcom. All Rights Reserved. The term *
55 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. *
66 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
77 * EMULEX and SLI are trademarks of Emulex. *
....@@ -44,7 +44,6 @@
4444 #include "lpfc_disc.h"
4545 #include "lpfc.h"
4646 #include "lpfc_scsi.h"
47
-#include "lpfc_nvme.h"
4847 #include "lpfc_logmsg.h"
4948 #include "lpfc_crtn.h"
5049 #include "lpfc_version.h"
....@@ -301,7 +300,7 @@
301300 return 0;
302301 }
303302
304
-/**
303
+/*
305304 * lpfc_gen_req - Build and issue a GEN_REQUEST command to the SLI Layer
306305 * @vport: pointer to a host virtual N_Port data structure.
307306 * @bmp: Pointer to BPL for SLI command
....@@ -388,6 +387,8 @@
388387 rc = lpfc_sli_issue_iocb(phba, LPFC_ELS_RING, geniocb, 0);
389388
390389 if (rc == IOCB_ERROR) {
390
+ geniocb->context_un.ndlp = NULL;
391
+ lpfc_nlp_put(ndlp);
391392 lpfc_sli_release_iocbq(phba, geniocb);
392393 return 1;
393394 }
....@@ -395,7 +396,7 @@
395396 return 0;
396397 }
397398
398
-/**
399
+/*
399400 * lpfc_ct_cmd - Build and issue a CT command
400401 * @vport: pointer to a host virtual N_Port data structure.
401402 * @inmp: Pointer to data buffer for response data.
....@@ -445,14 +446,14 @@
445446 struct lpfc_vport *vport_curr;
446447 unsigned long flags;
447448
448
- spin_lock_irqsave(&phba->hbalock, flags);
449
+ spin_lock_irqsave(&phba->port_list_lock, flags);
449450 list_for_each_entry(vport_curr, &phba->port_list, listentry) {
450451 if ((vport_curr->fc_myDID) && (vport_curr->fc_myDID == did)) {
451
- spin_unlock_irqrestore(&phba->hbalock, flags);
452
+ spin_unlock_irqrestore(&phba->port_list_lock, flags);
452453 return vport_curr;
453454 }
454455 }
455
- spin_unlock_irqrestore(&phba->hbalock, flags);
456
+ spin_unlock_irqrestore(&phba->port_list_lock, flags);
456457 return NULL;
457458 }
458459
....@@ -480,10 +481,20 @@
480481
481482 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
482483 "0238 Process x%06x NameServer Rsp "
483
- "Data: x%x x%x x%x x%x\n", Did,
484
+ "Data: x%x x%x x%x x%x x%x\n", Did,
484485 ndlp->nlp_flag, ndlp->nlp_fc4_type,
485
- vport->fc_flag,
486
+ ndlp->nlp_state, vport->fc_flag,
486487 vport->fc_rscn_id_cnt);
488
+
489
+ /* if ndlp needs to be discovered and prior
490
+ * state of ndlp hit devloss, change state to
491
+ * allow rediscovery.
492
+ */
493
+ if (ndlp->nlp_flag & NLP_NPR_2B_DISC &&
494
+ ndlp->nlp_state == NLP_STE_UNUSED_NODE) {
495
+ lpfc_nlp_set_state(vport, ndlp,
496
+ NLP_STE_NPR_NODE);
497
+ }
487498 } else {
488499 lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
489500 "Skip1 GID_FTrsp: did:x%x flg:x%x cnt:%d",
....@@ -491,9 +502,9 @@
491502
492503 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
493504 "0239 Skip x%06x NameServer Rsp "
494
- "Data: x%x x%x\n", Did,
495
- vport->fc_flag,
496
- vport->fc_rscn_id_cnt);
505
+ "Data: x%x x%x %p\n",
506
+ Did, vport->fc_flag,
507
+ vport->fc_rscn_id_cnt, ndlp);
497508 }
498509 } else {
499510 if (!(vport->fc_flag & FC_RSCN_MODE) ||
....@@ -540,7 +551,17 @@
540551 struct lpfc_hba *phba = vport->phba;
541552 struct lpfc_nodelist *ndlp = NULL;
542553 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
554
+ char *str;
543555
556
+ if (phba->cfg_ns_query == LPFC_NS_QUERY_GID_FT)
557
+ str = "GID_FT";
558
+ else
559
+ str = "GID_PT";
560
+ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
561
+ "6430 Process %s rsp for %08x type %x %s %s\n",
562
+ str, Did, fc4_type,
563
+ (fc4_type == FC_TYPE_FCP) ? "FCP" : " ",
564
+ (fc4_type == FC_TYPE_NVME) ? "NVME" : " ");
544565 /*
545566 * To conserve rpi's, filter out addresses for other
546567 * vports on the same physical HBAs.
....@@ -694,7 +715,8 @@
694715 /* This is a GID_FT completing so the gidft_inp counter was
695716 * incremented before the GID_FT was issued to the wire.
696717 */
697
- vport->gidft_inp--;
718
+ if (vport->gidft_inp)
719
+ vport->gidft_inp--;
698720
699721 /*
700722 * Skip processing the NS response
....@@ -722,16 +744,19 @@
722744 goto out;
723745
724746 /* CT command is being retried */
725
- vport->gidft_inp--;
726747 rc = lpfc_ns_cmd(vport, SLI_CTNS_GID_FT,
727748 vport->fc_ns_retry, type);
728749 if (rc == 0)
729750 goto out;
751
+ else { /* Unable to send NS cmd */
752
+ if (vport->gidft_inp)
753
+ vport->gidft_inp--;
754
+ }
730755 }
731756 if (vport->fc_flag & FC_RSCN_MODE)
732757 lpfc_els_flush_rscn(vport);
733758 lpfc_vport_set_state(vport, FC_VPORT_FAILED);
734
- lpfc_printf_vlog(vport, KERN_ERR, LOG_ELS,
759
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
735760 "0257 GID_FT Query error: 0x%x 0x%x\n",
736761 irsp->ulpStatus, vport->fc_ns_retry);
737762 } else {
....@@ -741,9 +766,13 @@
741766 if (CTrsp->CommandResponse.bits.CmdRsp ==
742767 cpu_to_be16(SLI_CT_RESPONSE_FS_ACC)) {
743768 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
744
- "0208 NameServer Rsp Data: x%x x%x\n",
769
+ "0208 NameServer Rsp Data: x%x x%x "
770
+ "x%x x%x sz x%x\n",
745771 vport->fc_flag,
746
- CTreq->un.gid.Fc4Type);
772
+ CTreq->un.gid.Fc4Type,
773
+ vport->num_disc_nodes,
774
+ vport->gidft_inp,
775
+ irsp->un.genreq64.bdl.bdeSize);
747776
748777 lpfc_ns_rsp(vport,
749778 outp,
....@@ -788,7 +817,7 @@
788817
789818 } else {
790819 /* NameServer Rsp Error */
791
- lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
820
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
792821 "0241 NameServer Rsp Error "
793822 "Data: x%x x%x x%x x%x\n",
794823 CTrsp->CommandResponse.bits.CmdRsp,
....@@ -802,8 +831,14 @@
802831 (uint32_t) CTrsp->ReasonCode,
803832 (uint32_t) CTrsp->Explanation);
804833 }
805
- vport->gidft_inp--;
834
+ if (vport->gidft_inp)
835
+ vport->gidft_inp--;
806836 }
837
+
838
+ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
839
+ "4216 GID_FT cmpl inp %d disc %d\n",
840
+ vport->gidft_inp, vport->num_disc_nodes);
841
+
807842 /* Link up / RSCN discovery */
808843 if ((vport->num_disc_nodes == 0) &&
809844 (vport->gidft_inp == 0)) {
....@@ -832,6 +867,212 @@
832867 }
833868
834869 static void
870
+lpfc_cmpl_ct_cmd_gid_pt(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
871
+ struct lpfc_iocbq *rspiocb)
872
+{
873
+ struct lpfc_vport *vport = cmdiocb->vport;
874
+ struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
875
+ IOCB_t *irsp;
876
+ struct lpfc_dmabuf *outp;
877
+ struct lpfc_dmabuf *inp;
878
+ struct lpfc_sli_ct_request *CTrsp;
879
+ struct lpfc_sli_ct_request *CTreq;
880
+ struct lpfc_nodelist *ndlp;
881
+ int rc;
882
+
883
+ /* First save ndlp, before we overwrite it */
884
+ ndlp = cmdiocb->context_un.ndlp;
885
+
886
+ /* we pass cmdiocb to state machine which needs rspiocb as well */
887
+ cmdiocb->context_un.rsp_iocb = rspiocb;
888
+ inp = (struct lpfc_dmabuf *)cmdiocb->context1;
889
+ outp = (struct lpfc_dmabuf *)cmdiocb->context2;
890
+ irsp = &rspiocb->iocb;
891
+
892
+ lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_CT,
893
+ "GID_PT cmpl: status:x%x/x%x rtry:%d",
894
+ irsp->ulpStatus, irsp->un.ulpWord[4],
895
+ vport->fc_ns_retry);
896
+
897
+ /* Don't bother processing response if vport is being torn down. */
898
+ if (vport->load_flag & FC_UNLOADING) {
899
+ if (vport->fc_flag & FC_RSCN_MODE)
900
+ lpfc_els_flush_rscn(vport);
901
+ goto out;
902
+ }
903
+
904
+ if (lpfc_els_chk_latt(vport)) {
905
+ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
906
+ "4108 Link event during NS query\n");
907
+ if (vport->fc_flag & FC_RSCN_MODE)
908
+ lpfc_els_flush_rscn(vport);
909
+ lpfc_vport_set_state(vport, FC_VPORT_FAILED);
910
+ goto out;
911
+ }
912
+ if (lpfc_error_lost_link(irsp)) {
913
+ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
914
+ "4166 NS query failed due to link event\n");
915
+ if (vport->fc_flag & FC_RSCN_MODE)
916
+ lpfc_els_flush_rscn(vport);
917
+ goto out;
918
+ }
919
+
920
+ spin_lock_irq(shost->host_lock);
921
+ if (vport->fc_flag & FC_RSCN_DEFERRED) {
922
+ vport->fc_flag &= ~FC_RSCN_DEFERRED;
923
+ spin_unlock_irq(shost->host_lock);
924
+
925
+ /* This is a GID_PT completing so the gidft_inp counter was
926
+ * incremented before the GID_PT was issued to the wire.
927
+ */
928
+ if (vport->gidft_inp)
929
+ vport->gidft_inp--;
930
+
931
+ /*
932
+ * Skip processing the NS response
933
+ * Re-issue the NS cmd
934
+ */
935
+ lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
936
+ "4167 Process Deferred RSCN Data: x%x x%x\n",
937
+ vport->fc_flag, vport->fc_rscn_id_cnt);
938
+ lpfc_els_handle_rscn(vport);
939
+
940
+ goto out;
941
+ }
942
+ spin_unlock_irq(shost->host_lock);
943
+
944
+ if (irsp->ulpStatus) {
945
+ /* Check for retry */
946
+ if (vport->fc_ns_retry < LPFC_MAX_NS_RETRY) {
947
+ if (irsp->ulpStatus != IOSTAT_LOCAL_REJECT ||
948
+ (irsp->un.ulpWord[4] & IOERR_PARAM_MASK) !=
949
+ IOERR_NO_RESOURCES)
950
+ vport->fc_ns_retry++;
951
+
952
+ /* CT command is being retried */
953
+ rc = lpfc_ns_cmd(vport, SLI_CTNS_GID_PT,
954
+ vport->fc_ns_retry, GID_PT_N_PORT);
955
+ if (rc == 0)
956
+ goto out;
957
+ else { /* Unable to send NS cmd */
958
+ if (vport->gidft_inp)
959
+ vport->gidft_inp--;
960
+ }
961
+ }
962
+ if (vport->fc_flag & FC_RSCN_MODE)
963
+ lpfc_els_flush_rscn(vport);
964
+ lpfc_vport_set_state(vport, FC_VPORT_FAILED);
965
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
966
+ "4103 GID_FT Query error: 0x%x 0x%x\n",
967
+ irsp->ulpStatus, vport->fc_ns_retry);
968
+ } else {
969
+ /* Good status, continue checking */
970
+ CTreq = (struct lpfc_sli_ct_request *)inp->virt;
971
+ CTrsp = (struct lpfc_sli_ct_request *)outp->virt;
972
+ if (CTrsp->CommandResponse.bits.CmdRsp ==
973
+ cpu_to_be16(SLI_CT_RESPONSE_FS_ACC)) {
974
+ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
975
+ "4105 NameServer Rsp Data: x%x x%x "
976
+ "x%x x%x sz x%x\n",
977
+ vport->fc_flag,
978
+ CTreq->un.gid.Fc4Type,
979
+ vport->num_disc_nodes,
980
+ vport->gidft_inp,
981
+ irsp->un.genreq64.bdl.bdeSize);
982
+
983
+ lpfc_ns_rsp(vport,
984
+ outp,
985
+ CTreq->un.gid.Fc4Type,
986
+ (uint32_t)(irsp->un.genreq64.bdl.bdeSize));
987
+ } else if (CTrsp->CommandResponse.bits.CmdRsp ==
988
+ be16_to_cpu(SLI_CT_RESPONSE_FS_RJT)) {
989
+ /* NameServer Rsp Error */
990
+ if ((CTrsp->ReasonCode == SLI_CT_UNABLE_TO_PERFORM_REQ)
991
+ && (CTrsp->Explanation == SLI_CT_NO_FC4_TYPES)) {
992
+ lpfc_printf_vlog(
993
+ vport, KERN_INFO, LOG_DISCOVERY,
994
+ "4106 No NameServer Entries "
995
+ "Data: x%x x%x x%x x%x\n",
996
+ CTrsp->CommandResponse.bits.CmdRsp,
997
+ (uint32_t)CTrsp->ReasonCode,
998
+ (uint32_t)CTrsp->Explanation,
999
+ vport->fc_flag);
1000
+
1001
+ lpfc_debugfs_disc_trc(
1002
+ vport, LPFC_DISC_TRC_CT,
1003
+ "GID_PT no entry cmd:x%x rsn:x%x exp:x%x",
1004
+ (uint32_t)CTrsp->CommandResponse.bits.CmdRsp,
1005
+ (uint32_t)CTrsp->ReasonCode,
1006
+ (uint32_t)CTrsp->Explanation);
1007
+ } else {
1008
+ lpfc_printf_vlog(
1009
+ vport, KERN_INFO, LOG_DISCOVERY,
1010
+ "4107 NameServer Rsp Error "
1011
+ "Data: x%x x%x x%x x%x\n",
1012
+ CTrsp->CommandResponse.bits.CmdRsp,
1013
+ (uint32_t)CTrsp->ReasonCode,
1014
+ (uint32_t)CTrsp->Explanation,
1015
+ vport->fc_flag);
1016
+
1017
+ lpfc_debugfs_disc_trc(
1018
+ vport, LPFC_DISC_TRC_CT,
1019
+ "GID_PT rsp err1 cmd:x%x rsn:x%x exp:x%x",
1020
+ (uint32_t)CTrsp->CommandResponse.bits.CmdRsp,
1021
+ (uint32_t)CTrsp->ReasonCode,
1022
+ (uint32_t)CTrsp->Explanation);
1023
+ }
1024
+ } else {
1025
+ /* NameServer Rsp Error */
1026
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1027
+ "4109 NameServer Rsp Error "
1028
+ "Data: x%x x%x x%x x%x\n",
1029
+ CTrsp->CommandResponse.bits.CmdRsp,
1030
+ (uint32_t)CTrsp->ReasonCode,
1031
+ (uint32_t)CTrsp->Explanation,
1032
+ vport->fc_flag);
1033
+
1034
+ lpfc_debugfs_disc_trc(
1035
+ vport, LPFC_DISC_TRC_CT,
1036
+ "GID_PT rsp err2 cmd:x%x rsn:x%x exp:x%x",
1037
+ (uint32_t)CTrsp->CommandResponse.bits.CmdRsp,
1038
+ (uint32_t)CTrsp->ReasonCode,
1039
+ (uint32_t)CTrsp->Explanation);
1040
+ }
1041
+ if (vport->gidft_inp)
1042
+ vport->gidft_inp--;
1043
+ }
1044
+
1045
+ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1046
+ "6450 GID_PT cmpl inp %d disc %d\n",
1047
+ vport->gidft_inp, vport->num_disc_nodes);
1048
+
1049
+ /* Link up / RSCN discovery */
1050
+ if ((vport->num_disc_nodes == 0) &&
1051
+ (vport->gidft_inp == 0)) {
1052
+ /*
1053
+ * The driver has cycled through all Nports in the RSCN payload.
1054
+ * Complete the handling by cleaning up and marking the
1055
+ * current driver state.
1056
+ */
1057
+ if (vport->port_state >= LPFC_DISC_AUTH) {
1058
+ if (vport->fc_flag & FC_RSCN_MODE) {
1059
+ lpfc_els_flush_rscn(vport);
1060
+ spin_lock_irq(shost->host_lock);
1061
+ vport->fc_flag |= FC_RSCN_MODE; /* RSCN still */
1062
+ spin_unlock_irq(shost->host_lock);
1063
+ } else {
1064
+ lpfc_els_flush_rscn(vport);
1065
+ }
1066
+ }
1067
+
1068
+ lpfc_disc_start(vport);
1069
+ }
1070
+out:
1071
+ cmdiocb->context_un.ndlp = ndlp; /* Now restore ndlp for free */
1072
+ lpfc_ct_free_iocb(phba, cmdiocb);
1073
+}
1074
+
1075
+static void
8351076 lpfc_cmpl_ct_cmd_gff_id(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
8361077 struct lpfc_iocbq *rspiocb)
8371078 {
....@@ -856,6 +1097,13 @@
8561097 /* Good status, continue checking */
8571098 CTrsp = (struct lpfc_sli_ct_request *) outp->virt;
8581099 fbits = CTrsp->un.gff_acc.fbits[FCP_TYPE_FEATURE_OFFSET];
1100
+
1101
+ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1102
+ "6431 Process GFF_ID rsp for %08x "
1103
+ "fbits %02x %s %s\n",
1104
+ did, fbits,
1105
+ (fbits & FC4_FEATURE_INIT) ? "Initiator" : " ",
1106
+ (fbits & FC4_FEATURE_TARGET) ? "Target" : " ");
8591107
8601108 if (CTrsp->CommandResponse.bits.CmdRsp ==
8611109 be16_to_cpu(SLI_CT_RESPONSE_FS_ACC)) {
....@@ -907,7 +1155,7 @@
9071155 }
9081156 }
9091157 }
910
- lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
1158
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
9111159 "0267 NameServer GFF Rsp "
9121160 "x%x Error (%d %d) Data: x%x x%x\n",
9131161 did, irsp->ulpStatus, irsp->un.ulpWord[4],
....@@ -932,6 +1180,11 @@
9321180 /* Link up / RSCN discovery */
9331181 if (vport->num_disc_nodes)
9341182 vport->num_disc_nodes--;
1183
+
1184
+ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1185
+ "6451 GFF_ID cmpl inp %d disc %d\n",
1186
+ vport->gidft_inp, vport->num_disc_nodes);
1187
+
9351188 if (vport->num_disc_nodes == 0) {
9361189 /*
9371190 * The driver has cycled through all Nports in the RSCN payload.
....@@ -979,9 +1232,15 @@
9791232 CTrsp = (struct lpfc_sli_ct_request *)outp->virt;
9801233 fc4_data_0 = be32_to_cpu(CTrsp->un.gft_acc.fc4_types[0]);
9811234 fc4_data_1 = be32_to_cpu(CTrsp->un.gft_acc.fc4_types[1]);
1235
+
9821236 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
983
- "3062 DID x%06x GFT Wd0 x%08x Wd1 x%08x\n",
984
- did, fc4_data_0, fc4_data_1);
1237
+ "6432 Process GFT_ID rsp for %08x "
1238
+ "Data %08x %08x %s %s\n",
1239
+ did, fc4_data_0, fc4_data_1,
1240
+ (fc4_data_0 & LPFC_FC4_TYPE_BITMASK) ?
1241
+ "FCP" : " ",
1242
+ (fc4_data_1 & LPFC_FC4_TYPE_BITMASK) ?
1243
+ "NVME" : " ");
9851244
9861245 ndlp = lpfc_findnode_did(vport, did);
9871246 if (ndlp) {
....@@ -994,17 +1253,37 @@
9941253 if (fc4_data_1 & LPFC_FC4_TYPE_BITMASK)
9951254 ndlp->nlp_fc4_type |= NLP_FC4_NVME;
9961255 lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
997
- "3064 Setting ndlp %p, DID x%06x with "
998
- "FC4 x%08x, Data: x%08x x%08x\n",
1256
+ "3064 Setting ndlp x%px, DID x%06x "
1257
+ "with FC4 x%08x, Data: x%08x x%08x "
1258
+ "%d\n",
9991259 ndlp, did, ndlp->nlp_fc4_type,
1000
- FC_TYPE_FCP, FC_TYPE_NVME);
1001
- ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1260
+ FC_TYPE_FCP, FC_TYPE_NVME,
1261
+ ndlp->nlp_state);
10021262
1003
- lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE);
1004
- lpfc_issue_els_prli(vport, ndlp, 0);
1263
+ if (ndlp->nlp_state == NLP_STE_REG_LOGIN_ISSUE &&
1264
+ ndlp->nlp_fc4_type) {
1265
+ ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1266
+
1267
+ lpfc_nlp_set_state(vport, ndlp,
1268
+ NLP_STE_PRLI_ISSUE);
1269
+ lpfc_issue_els_prli(vport, ndlp, 0);
1270
+ } else if (!ndlp->nlp_fc4_type) {
1271
+ /* If fc4 type is still unknown, then LOGO */
1272
+ lpfc_printf_vlog(vport, KERN_INFO,
1273
+ LOG_DISCOVERY,
1274
+ "6443 Sending LOGO ndlp x%px,"
1275
+ "DID x%06x with fc4_type: "
1276
+ "x%08x, state: %d\n",
1277
+ ndlp, did, ndlp->nlp_fc4_type,
1278
+ ndlp->nlp_state);
1279
+ lpfc_issue_els_logo(vport, ndlp, 0);
1280
+ ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
1281
+ lpfc_nlp_set_state(vport, ndlp,
1282
+ NLP_STE_NPR_NODE);
1283
+ }
10051284 }
10061285 } else
1007
- lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
1286
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
10081287 "3065 GFT_ID failed x%08x\n", irsp->ulpStatus);
10091288
10101289 lpfc_ct_free_iocb(phba, cmdiocb);
....@@ -1053,7 +1332,7 @@
10531332 irsp->ulpStatus, irsp->un.ulpWord[4], cmdcode);
10541333
10551334 if (irsp->ulpStatus) {
1056
- lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
1335
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
10571336 "0268 NS cmd x%x Error (x%x x%x)\n",
10581337 cmdcode, irsp->ulpStatus, irsp->un.ulpWord[4]);
10591338
....@@ -1224,33 +1503,35 @@
12241503 lpfc_vport_symbolic_node_name(struct lpfc_vport *vport, char *symbol,
12251504 size_t size)
12261505 {
1227
- char fwrev[FW_REV_STR_SIZE];
1228
- int n;
1506
+ char fwrev[FW_REV_STR_SIZE] = {0};
1507
+ char tmp[MAXHOSTNAMELEN] = {0};
1508
+
1509
+ memset(symbol, 0, size);
1510
+
1511
+ scnprintf(tmp, sizeof(tmp), "Emulex %s", vport->phba->ModelName);
1512
+ if (strlcat(symbol, tmp, size) >= size)
1513
+ goto buffer_done;
12291514
12301515 lpfc_decode_firmware_rev(vport->phba, fwrev, 0);
1516
+ scnprintf(tmp, sizeof(tmp), " FV%s", fwrev);
1517
+ if (strlcat(symbol, tmp, size) >= size)
1518
+ goto buffer_done;
12311519
1232
- n = scnprintf(symbol, size, "Emulex %s", vport->phba->ModelName);
1233
- if (size < n)
1234
- return n;
1520
+ scnprintf(tmp, sizeof(tmp), " DV%s", lpfc_release_version);
1521
+ if (strlcat(symbol, tmp, size) >= size)
1522
+ goto buffer_done;
12351523
1236
- n += scnprintf(symbol + n, size - n, " FV%s", fwrev);
1237
- if (size < n)
1238
- return n;
1239
-
1240
- n += scnprintf(symbol + n, size - n, " DV%s.",
1241
- lpfc_release_version);
1242
- if (size < n)
1243
- return n;
1244
-
1245
- n += scnprintf(symbol + n, size - n, " HN:%s.",
1246
- init_utsname()->nodename);
1247
- if (size < n)
1248
- return n;
1524
+ scnprintf(tmp, sizeof(tmp), " HN:%s", vport->phba->os_host_name);
1525
+ if (strlcat(symbol, tmp, size) >= size)
1526
+ goto buffer_done;
12491527
12501528 /* Note :- OS name is "Linux" */
1251
- n += scnprintf(symbol + n, size - n, " OS:%s\n",
1252
- init_utsname()->sysname);
1253
- return n;
1529
+ scnprintf(tmp, sizeof(tmp), " OS:%s", init_utsname()->sysname);
1530
+ strlcat(symbol, tmp, size);
1531
+
1532
+buffer_done:
1533
+ return strnlen(symbol, size);
1534
+
12541535 }
12551536
12561537 static uint32_t
....@@ -1312,6 +1593,7 @@
13121593 struct ulp_bde64 *bpl;
13131594 void (*cmpl) (struct lpfc_hba *, struct lpfc_iocbq *,
13141595 struct lpfc_iocbq *) = NULL;
1596
+ uint32_t *ptr;
13151597 uint32_t rsp_size = 1024;
13161598 size_t size;
13171599 int rc = 0;
....@@ -1365,6 +1647,8 @@
13651647 bpl->tus.f.bdeFlags = 0;
13661648 if (cmdcode == SLI_CTNS_GID_FT)
13671649 bpl->tus.f.bdeSize = GID_REQUEST_SZ;
1650
+ else if (cmdcode == SLI_CTNS_GID_PT)
1651
+ bpl->tus.f.bdeSize = GID_REQUEST_SZ;
13681652 else if (cmdcode == SLI_CTNS_GFF_ID)
13691653 bpl->tus.f.bdeSize = GFF_REQUEST_SZ;
13701654 else if (cmdcode == SLI_CTNS_GFT_ID)
....@@ -1405,6 +1689,18 @@
14051689 rsp_size = FC_MAX_NS_RSP;
14061690 break;
14071691
1692
+ case SLI_CTNS_GID_PT:
1693
+ CtReq->CommandResponse.bits.CmdRsp =
1694
+ cpu_to_be16(SLI_CTNS_GID_PT);
1695
+ CtReq->un.gid.PortType = context;
1696
+
1697
+ if (vport->port_state < LPFC_NS_QRY)
1698
+ vport->port_state = LPFC_NS_QRY;
1699
+ lpfc_set_disctmo(vport);
1700
+ cmpl = lpfc_cmpl_ct_cmd_gid_pt;
1701
+ rsp_size = FC_MAX_NS_RSP;
1702
+ break;
1703
+
14081704 case SLI_CTNS_GFF_ID:
14091705 CtReq->CommandResponse.bits.CmdRsp =
14101706 cpu_to_be16(SLI_CTNS_GFF_ID);
....@@ -1426,18 +1722,28 @@
14261722 CtReq->un.rft.PortId = cpu_to_be32(vport->fc_myDID);
14271723
14281724 /* Register FC4 FCP type if enabled. */
1429
- if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1430
- (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP))
1725
+ if (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH ||
1726
+ vport->cfg_enable_fc4_type == LPFC_ENABLE_FCP)
14311727 CtReq->un.rft.fcpReg = 1;
14321728
14331729 /* Register NVME type if enabled. Defined LE and swapped.
14341730 * rsvd[0] is used as word1 because of the hard-coded
14351731 * word0 usage in the ct_request data structure.
14361732 */
1437
- if ((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1438
- (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME))
1439
- CtReq->un.rft.rsvd[0] = cpu_to_be32(0x00000100);
1733
+ if (vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH ||
1734
+ vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)
1735
+ CtReq->un.rft.rsvd[0] =
1736
+ cpu_to_be32(LPFC_FC4_TYPE_BITMASK);
14401737
1738
+ ptr = (uint32_t *)CtReq;
1739
+ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1740
+ "6433 Issue RFT (%s %s): %08x %08x %08x %08x "
1741
+ "%08x %08x %08x %08x\n",
1742
+ CtReq->un.rft.fcpReg ? "FCP" : " ",
1743
+ CtReq->un.rft.rsvd[0] ? "NVME" : " ",
1744
+ *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3),
1745
+ *(ptr + 4), *(ptr + 5),
1746
+ *(ptr + 6), *(ptr + 7));
14411747 cmpl = lpfc_cmpl_ct_cmd_rft_id;
14421748 break;
14431749
....@@ -1492,8 +1798,8 @@
14921798 * caller can specify NVME (type x28) as well. But only
14931799 * these that FC4 type is supported.
14941800 */
1495
- if (((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1496
- (phba->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) &&
1801
+ if (((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1802
+ (vport->cfg_enable_fc4_type == LPFC_ENABLE_NVME)) &&
14971803 (context == FC_TYPE_NVME)) {
14981804 if ((vport == phba->pport) && phba->nvmet_support) {
14991805 CtReq->un.rff.fbits = (FC4_FEATURE_TARGET |
....@@ -1504,14 +1810,22 @@
15041810 }
15051811 CtReq->un.rff.type_code = context;
15061812
1507
- } else if (((phba->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1508
- (phba->cfg_enable_fc4_type == LPFC_ENABLE_FCP)) &&
1813
+ } else if (((vport->cfg_enable_fc4_type == LPFC_ENABLE_BOTH) ||
1814
+ (vport->cfg_enable_fc4_type == LPFC_ENABLE_FCP)) &&
15091815 (context == FC_TYPE_FCP))
15101816 CtReq->un.rff.type_code = context;
15111817
15121818 else
15131819 goto ns_cmd_free_bmpvirt;
15141820
1821
+ ptr = (uint32_t *)CtReq;
1822
+ lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
1823
+ "6434 Issue RFF (%s): %08x %08x %08x %08x "
1824
+ "%08x %08x %08x %08x\n",
1825
+ (context == FC_TYPE_NVME) ? "NVME" : "FCP",
1826
+ *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3),
1827
+ *(ptr + 4), *(ptr + 5),
1828
+ *(ptr + 6), *(ptr + 7));
15151829 cmpl = lpfc_cmpl_ct_cmd_rff_id;
15161830 break;
15171831 }
....@@ -1541,7 +1855,7 @@
15411855 ns_cmd_free_mp:
15421856 kfree(mp);
15431857 ns_cmd_exit:
1544
- lpfc_printf_vlog(vport, KERN_ERR, LOG_DISCOVERY,
1858
+ lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
15451859 "0266 Issue NameServer Req x%x err %d Data: x%x x%x\n",
15461860 cmdcode, rc, vport->fc_flag, vport->fc_rscn_id_cnt);
15471861 return 1;
....@@ -1582,6 +1896,12 @@
15821896 if (irsp->ulpStatus == IOSTAT_LOCAL_REJECT) {
15831897 switch ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK)) {
15841898 case IOERR_SLI_ABORTED:
1899
+ case IOERR_SLI_DOWN:
1900
+ /* Driver aborted this IO. No retry as error
1901
+ * is likely Offline->Online or some adapter
1902
+ * error. Recovery will try again.
1903
+ */
1904
+ break;
15851905 case IOERR_ABORT_IN_PROGRESS:
15861906 case IOERR_SEQUENCE_TIMEOUT:
15871907 case IOERR_ILLEGAL_FRAME:
....@@ -1690,14 +2010,16 @@
16902010
16912011
16922012 /**
1693
- * lpfc_fdmi_num_disc_check - Check how many mapped NPorts we are connected to
2013
+ * lpfc_fdmi_change_check - Check for changed FDMI parameters
16942014 * @vport: pointer to a host virtual N_Port data structure.
16952015 *
1696
- * Called from hbeat timeout routine to check if the number of discovered
1697
- * ports has changed. If so, re-register thar port Attribute.
2016
+ * Check how many mapped NPorts we are connected to
2017
+ * Check if our hostname changed
2018
+ * Called from hbeat timeout routine to check if any FDMI parameters
2019
+ * changed. If so, re-register those Attributes.
16982020 */
16992021 void
1700
-lpfc_fdmi_num_disc_check(struct lpfc_vport *vport)
2022
+lpfc_fdmi_change_check(struct lpfc_vport *vport)
17012023 {
17022024 struct lpfc_hba *phba = vport->phba;
17032025 struct lpfc_nodelist *ndlp;
....@@ -1710,15 +2032,39 @@
17102032 if (!(vport->fc_flag & FC_FABRIC))
17112033 return;
17122034
2035
+ ndlp = lpfc_findnode_did(vport, FDMI_DID);
2036
+ if (!ndlp || !NLP_CHK_NODE_ACT(ndlp))
2037
+ return;
2038
+
2039
+ /* Check if system hostname changed */
2040
+ if (strcmp(phba->os_host_name, init_utsname()->nodename)) {
2041
+ memset(phba->os_host_name, 0, sizeof(phba->os_host_name));
2042
+ scnprintf(phba->os_host_name, sizeof(phba->os_host_name), "%s",
2043
+ init_utsname()->nodename);
2044
+ lpfc_ns_cmd(vport, SLI_CTNS_RSNN_NN, 0, 0);
2045
+
2046
+ /* Since this effects multiple HBA and PORT attributes, we need
2047
+ * de-register and go thru the whole FDMI registration cycle.
2048
+ * DHBA -> DPRT -> RHBA -> RPA (physical port)
2049
+ * DPRT -> RPRT (vports)
2050
+ */
2051
+ if (vport->port_type == LPFC_PHYSICAL_PORT)
2052
+ lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DHBA, 0);
2053
+ else
2054
+ lpfc_fdmi_cmd(vport, ndlp, SLI_MGMT_DPRT, 0);
2055
+
2056
+ /* Since this code path registers all the port attributes
2057
+ * we can just return without further checking.
2058
+ */
2059
+ return;
2060
+ }
2061
+
17132062 if (!(vport->fdmi_port_mask & LPFC_FDMI_PORT_ATTR_num_disc))
17142063 return;
17152064
2065
+ /* Check if the number of mapped NPorts changed */
17162066 cnt = lpfc_find_map_node(vport);
17172067 if (cnt == vport->fdmi_num_disc)
1718
- return;
1719
-
1720
- ndlp = lpfc_findnode_did(vport, FDMI_DID);
1721
- if (!ndlp || !NLP_CHK_NODE_ACT(ndlp))
17222068 return;
17232069
17242070 if (vport->port_type == LPFC_PHYSICAL_PORT) {
....@@ -2056,7 +2402,8 @@
20562402 ae = &ad->AttrValue;
20572403 memset(ae, 0, sizeof(*ae));
20582404
2059
- lpfc_decode_firmware_rev(phba, ae->un.AttrString, 1);
2405
+ strlcat(ae->un.AttrString, phba->BIOSVersion,
2406
+ sizeof(ae->un.AttrString));
20602407 len = strnlen(ae->un.AttrString,
20612408 sizeof(ae->un.AttrString));
20622409 len += (len & 3) ? (4 - (len & 3)) : 4;
....@@ -2109,17 +2456,21 @@
21092456 lpfc_fdmi_port_attr_fc4type(struct lpfc_vport *vport,
21102457 struct lpfc_fdmi_attr_def *ad)
21112458 {
2459
+ struct lpfc_hba *phba = vport->phba;
21122460 struct lpfc_fdmi_attr_entry *ae;
21132461 uint32_t size;
21142462
21152463 ae = &ad->AttrValue;
21162464 memset(ae, 0, sizeof(*ae));
21172465
2118
- ae->un.AttrTypes[3] = 0x02; /* Type 0x1 - ELS */
21192466 ae->un.AttrTypes[2] = 0x01; /* Type 0x8 - FCP */
2120
- if (vport->nvmei_support || vport->phba->nvmet_support)
2121
- ae->un.AttrTypes[6] = 0x01; /* Type 0x28 - NVME */
21222467 ae->un.AttrTypes[7] = 0x01; /* Type 0x20 - CT */
2468
+
2469
+ /* Check to see if Firmware supports NVME and on physical port */
2470
+ if ((phba->sli_rev == LPFC_SLI_REV4) && (vport == phba->pport) &&
2471
+ phba->sli4_hba.pc_sli4_params.nvme)
2472
+ ae->un.AttrTypes[6] = 0x01; /* Type 0x28 - NVME */
2473
+
21232474 size = FOURBYTES + 32;
21242475 ad->AttrLen = cpu_to_be16(size);
21252476 ad->AttrType = cpu_to_be16(RPRT_SUPPORTED_FC4_TYPES);
....@@ -2138,6 +2489,8 @@
21382489
21392490 ae->un.AttrInt = 0;
21402491 if (!(phba->hba_flag & HBA_FCOE_MODE)) {
2492
+ if (phba->lmt & LMT_128Gb)
2493
+ ae->un.AttrInt |= HBA_PORTSPEED_128GFC;
21412494 if (phba->lmt & LMT_64Gb)
21422495 ae->un.AttrInt |= HBA_PORTSPEED_64GFC;
21432496 if (phba->lmt & LMT_32Gb)
....@@ -2214,6 +2567,9 @@
22142567 case LPFC_LINK_SPEED_64GHZ:
22152568 ae->un.AttrInt = HBA_PORTSPEED_64GFC;
22162569 break;
2570
+ case LPFC_LINK_SPEED_128GHZ:
2571
+ ae->un.AttrInt = HBA_PORTSPEED_128GFC;
2572
+ break;
22172573 default:
22182574 ae->un.AttrInt = HBA_PORTSPEED_UNKNOWN;
22192575 break;
....@@ -2256,7 +2612,7 @@
22562612 ae = &ad->AttrValue;
22572613
22582614 hsp = (struct serv_parm *)&vport->fc_sparam;
2259
- ae->un.AttrInt = (((uint32_t) hsp->cmn.bbRcvSizeMsb) << 8) |
2615
+ ae->un.AttrInt = (((uint32_t) hsp->cmn.bbRcvSizeMsb & 0x0F) << 8) |
22602616 (uint32_t) hsp->cmn.bbRcvSizeLsb;
22612617 ae->un.AttrInt = cpu_to_be32(ae->un.AttrInt);
22622618 size = FOURBYTES + sizeof(uint32_t);
....@@ -2297,8 +2653,8 @@
22972653 ae = &ad->AttrValue;
22982654 memset(ae, 0, sizeof(*ae));
22992655
2300
- snprintf(ae->un.AttrString, sizeof(ae->un.AttrString), "%s",
2301
- init_utsname()->nodename);
2656
+ scnprintf(ae->un.AttrString, sizeof(ae->un.AttrString), "%s",
2657
+ vport->phba->os_host_name);
23022658
23032659 len = strnlen(ae->un.AttrString, sizeof(ae->un.AttrString));
23042660 len += (len & 3) ? (4 - (len & 3)) : 4;
....@@ -2424,11 +2780,13 @@
24242780 ae = &ad->AttrValue;
24252781 memset(ae, 0, sizeof(*ae));
24262782
2427
- ae->un.AttrTypes[3] = 0x02; /* Type 0x1 - ELS */
24282783 ae->un.AttrTypes[2] = 0x01; /* Type 0x8 - FCP */
2784
+ ae->un.AttrTypes[7] = 0x01; /* Type 0x20 - CT */
2785
+
2786
+ /* Check to see if NVME is configured or not */
24292787 if (vport->phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)
24302788 ae->un.AttrTypes[6] = 0x1; /* Type 0x28 - NVME */
2431
- ae->un.AttrTypes[7] = 0x01; /* Type 0x20 - CT */
2789
+
24322790 size = FOURBYTES + 32;
24332791 ad->AttrLen = cpu_to_be16(size);
24342792 ad->AttrType = cpu_to_be16(RPRT_ACTIVE_FC4_TYPES);
....@@ -2673,8 +3031,8 @@
26733031 * lpfc_fdmi_cmd - Build and send a FDMI cmd to the specified NPort
26743032 * @vport: pointer to a host virtual N_Port data structure.
26753033 * @ndlp: ndlp to send FDMI cmd to (if NULL use FDMI_DID)
2676
- * cmdcode: FDMI command to send
2677
- * mask: Mask of HBA or PORT Attributes to send
3034
+ * @cmdcode: FDMI command to send
3035
+ * @new_mask: Mask of HBA or PORT Attributes to send
26783036 *
26793037 * Builds and sends a FDMI command using the CT subsystem.
26803038 */
....@@ -2846,6 +3204,7 @@
28463204 case SLI_MGMT_GHAT:
28473205 case SLI_MGMT_GRPL:
28483206 rsp_size = FC_MAX_NS_RSP;
3207
+ fallthrough;
28493208 case SLI_MGMT_DHBA:
28503209 case SLI_MGMT_DHAT:
28513210 pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID;
....@@ -2858,6 +3217,7 @@
28583217 case SLI_MGMT_GPAT:
28593218 case SLI_MGMT_GPAS:
28603219 rsp_size = FC_MAX_NS_RSP;
3220
+ fallthrough;
28613221 case SLI_MGMT_DPRT:
28623222 case SLI_MGMT_DPA:
28633223 pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID;
....@@ -2914,7 +3274,7 @@
29143274
29153275 /**
29163276 * lpfc_delayed_disc_tmo - Timeout handler for delayed discovery timer.
2917
- * @ptr - Context object of the timer.
3277
+ * @t: Context object of the timer.
29183278 *
29193279 * This function set the WORKER_DELAYED_DISC_TMO flag and wake up
29203280 * the worker thread.