@@ -181,11 +181,6 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
181
181
if (!vha -> flags .online )
182
182
goto done ;
183
183
184
- if ((fcport -> fw_login_state == DSC_LS_PLOGI_PEND ) ||
185
- (fcport -> fw_login_state == DSC_LS_PLOGI_COMP ) ||
186
- (fcport -> fw_login_state == DSC_LS_PRLI_PEND ))
187
- goto done ;
188
-
189
184
sp = qla2x00_get_sp (vha , fcport , GFP_KERNEL );
190
185
if (!sp )
191
186
goto done ;
@@ -1013,6 +1008,43 @@ void qla24xx_handle_gpdb_event(scsi_qla_host_t *vha, struct event_arg *ea)
1013
1008
spin_unlock_irqrestore (& vha -> hw -> tgt .sess_lock , flags );
1014
1009
} /* gpdb event */
1015
1010
1011
+
1012
+ static void qla_chk_n2n_b4_login (struct scsi_qla_host * vha , fc_port_t * fcport )
1013
+ {
1014
+ u8 login = 0 ;
1015
+
1016
+ if (qla_tgt_mode_enabled (vha ))
1017
+ return ;
1018
+
1019
+ if (qla_dual_mode_enabled (vha )) {
1020
+ if (N2N_TOPO (vha -> hw )) {
1021
+ u64 mywwn , wwn ;
1022
+
1023
+ mywwn = wwn_to_u64 (vha -> port_name );
1024
+ wwn = wwn_to_u64 (fcport -> port_name );
1025
+ if (mywwn > wwn )
1026
+ login = 1 ;
1027
+ else if ((fcport -> fw_login_state == DSC_LS_PLOGI_COMP )
1028
+ && time_after_eq (jiffies ,
1029
+ fcport -> plogi_nack_done_deadline ))
1030
+ login = 1 ;
1031
+ } else {
1032
+ login = 1 ;
1033
+ }
1034
+ } else {
1035
+ /* initiator mode */
1036
+ login = 1 ;
1037
+ }
1038
+
1039
+ if (login ) {
1040
+ ql_dbg (ql_dbg_disc , vha , 0x20bf ,
1041
+ "%s %d %8phC post login\n" ,
1042
+ __func__ , __LINE__ , fcport -> port_name );
1043
+ fcport -> disc_state = DSC_LOGIN_PEND ;
1044
+ qla2x00_post_async_login_work (vha , fcport , NULL );
1045
+ }
1046
+ }
1047
+
1016
1048
int qla24xx_fcport_handle_login (struct scsi_qla_host * vha , fc_port_t * fcport )
1017
1049
{
1018
1050
u16 data [2 ];
@@ -1037,8 +1069,10 @@ int qla24xx_fcport_handle_login(struct scsi_qla_host *vha, fc_port_t *fcport)
1037
1069
return 0 ;
1038
1070
1039
1071
if (fcport -> fw_login_state == DSC_LS_PLOGI_COMP ) {
1040
- if (time_before_eq (jiffies , fcport -> plogi_nack_done_deadline ))
1072
+ if (time_before_eq (jiffies , fcport -> plogi_nack_done_deadline )) {
1073
+ set_bit (RELOGIN_NEEDED , & vha -> dpc_flags );
1041
1074
return 0 ;
1075
+ }
1042
1076
}
1043
1077
1044
1078
/* for pure Target Mode. Login will not be initiated */
@@ -1058,11 +1092,7 @@ int qla24xx_fcport_handle_login(struct scsi_qla_host *vha, fc_port_t *fcport)
1058
1092
__func__ , __LINE__ , fcport -> port_name );
1059
1093
qla24xx_post_gnl_work (vha , fcport );
1060
1094
} else {
1061
- ql_dbg (ql_dbg_disc , vha , 0x20bf ,
1062
- "%s %d %8phC post login\n" ,
1063
- __func__ , __LINE__ , fcport -> port_name );
1064
- fcport -> disc_state = DSC_LOGIN_PEND ;
1065
- qla2x00_post_async_login_work (vha , fcport , NULL );
1095
+ qla_chk_n2n_b4_login (vha , fcport );
1066
1096
}
1067
1097
break ;
1068
1098
@@ -1074,19 +1104,17 @@ int qla24xx_fcport_handle_login(struct scsi_qla_host *vha, fc_port_t *fcport)
1074
1104
break ;
1075
1105
}
1076
1106
1077
- ql_dbg (ql_dbg_disc , vha , 0x20cf ,
1078
- "%s %d %8phC post login\n" ,
1079
- __func__ , __LINE__ , fcport -> port_name );
1080
- fcport -> disc_state = DSC_LOGIN_PEND ;
1081
- qla2x00_post_async_login_work (vha , fcport , NULL );
1107
+ qla_chk_n2n_b4_login (vha , fcport );
1082
1108
break ;
1083
1109
1084
1110
case DSC_LOGIN_FAILED :
1085
1111
ql_dbg (ql_dbg_disc , vha , 0x20d0 ,
1086
1112
"%s %d %8phC post gidpn\n" ,
1087
1113
__func__ , __LINE__ , fcport -> port_name );
1088
-
1089
- qla24xx_post_gidpn_work (vha , fcport );
1114
+ if (N2N_TOPO (vha -> hw ))
1115
+ qla_chk_n2n_b4_login (vha , fcport );
1116
+ else
1117
+ qla24xx_post_gidpn_work (vha , fcport );
1090
1118
break ;
1091
1119
1092
1120
case DSC_LOGIN_COMPLETE :
@@ -1193,8 +1221,10 @@ void qla24xx_handle_relogin_event(scsi_qla_host_t *vha,
1193
1221
return ;
1194
1222
1195
1223
if (fcport -> fw_login_state == DSC_LS_PLOGI_COMP ) {
1196
- if (time_before_eq (jiffies , fcport -> plogi_nack_done_deadline ))
1224
+ if (time_before_eq (jiffies , fcport -> plogi_nack_done_deadline )) {
1225
+ set_bit (RELOGIN_NEEDED , & vha -> dpc_flags );
1197
1226
return ;
1227
+ }
1198
1228
}
1199
1229
1200
1230
if (fcport -> flags & FCF_ASYNC_SENT ) {
@@ -4434,6 +4464,21 @@ qla2x00_configure_loop(scsi_qla_host_t *vha)
4434
4464
4435
4465
} else if (ha -> current_topology == ISP_CFG_N ) {
4436
4466
clear_bit (RSCN_UPDATE , & flags );
4467
+ if (ha -> flags .rida_fmt2 ) {
4468
+ /* With Rida Format 2, the login is already triggered.
4469
+ * We know who is on the other side of the wire.
4470
+ * No need to login to do login to find out or drop into
4471
+ * qla2x00_configure_local_loop().
4472
+ */
4473
+ clear_bit (LOCAL_LOOP_UPDATE , & flags );
4474
+ set_bit (RELOGIN_NEEDED , & vha -> dpc_flags );
4475
+ } else {
4476
+ if (qla_tgt_mode_enabled (vha )) {
4477
+ /* allow the other side to start the login */
4478
+ clear_bit (LOCAL_LOOP_UPDATE , & flags );
4479
+ set_bit (RELOGIN_NEEDED , & vha -> dpc_flags );
4480
+ }
4481
+ }
4437
4482
} else if (ha -> current_topology == ISP_CFG_NL ) {
4438
4483
clear_bit (RSCN_UPDATE , & flags );
4439
4484
set_bit (LOCAL_LOOP_UPDATE , & flags );
@@ -4662,6 +4707,10 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
4662
4707
(uint8_t * )ha -> gid_list ,
4663
4708
entries * sizeof (struct gid_list_info ));
4664
4709
4710
+ list_for_each_entry (fcport , & vha -> vp_fcports , list ) {
4711
+ fcport -> scan_state = QLA_FCPORT_SCAN ;
4712
+ }
4713
+
4665
4714
/* Allocate temporary fcport for any new fcports discovered. */
4666
4715
new_fcport = qla2x00_alloc_fcport (vha , GFP_KERNEL );
4667
4716
if (new_fcport == NULL ) {
@@ -4672,22 +4721,6 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
4672
4721
}
4673
4722
new_fcport -> flags &= ~FCF_FABRIC_DEVICE ;
4674
4723
4675
- /*
4676
- * Mark local devices that were present with FCF_DEVICE_LOST for now.
4677
- */
4678
- list_for_each_entry (fcport , & vha -> vp_fcports , list ) {
4679
- if (atomic_read (& fcport -> state ) == FCS_ONLINE &&
4680
- fcport -> port_type != FCT_BROADCAST &&
4681
- (fcport -> flags & FCF_FABRIC_DEVICE ) == 0 ) {
4682
-
4683
- ql_dbg (ql_dbg_disc , vha , 0x2096 ,
4684
- "Marking port lost loop_id=0x%04x.\n" ,
4685
- fcport -> loop_id );
4686
-
4687
- qla2x00_mark_device_lost (vha , fcport , 0 , 0 );
4688
- }
4689
- }
4690
-
4691
4724
/* Inititae N2N login. */
4692
4725
if (test_and_clear_bit (N2N_LOGIN_NEEDED , & vha -> dpc_flags )) {
4693
4726
rval = qla24xx_n2n_handle_login (vha , new_fcport );
@@ -4730,6 +4763,7 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
4730
4763
new_fcport -> d_id .b .area = area ;
4731
4764
new_fcport -> d_id .b .al_pa = al_pa ;
4732
4765
new_fcport -> loop_id = loop_id ;
4766
+ new_fcport -> scan_state = QLA_FCPORT_FOUND ;
4733
4767
4734
4768
rval2 = qla2x00_get_port_database (vha , new_fcport , 0 );
4735
4769
if (rval2 != QLA_SUCCESS ) {
@@ -4761,13 +4795,7 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
4761
4795
fcport -> d_id .b24 = new_fcport -> d_id .b24 ;
4762
4796
memcpy (fcport -> node_name , new_fcport -> node_name ,
4763
4797
WWN_SIZE );
4764
-
4765
- if (!fcport -> login_succ ) {
4766
- vha -> fcport_count ++ ;
4767
- fcport -> login_succ = 1 ;
4768
- fcport -> disc_state = DSC_LOGIN_COMPLETE ;
4769
- }
4770
-
4798
+ fcport -> scan_state = QLA_FCPORT_FOUND ;
4771
4799
found ++ ;
4772
4800
break ;
4773
4801
}
@@ -4778,11 +4806,6 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
4778
4806
4779
4807
/* Allocate a new replacement fcport. */
4780
4808
fcport = new_fcport ;
4781
- if (!fcport -> login_succ ) {
4782
- vha -> fcport_count ++ ;
4783
- fcport -> login_succ = 1 ;
4784
- fcport -> disc_state = DSC_LOGIN_COMPLETE ;
4785
- }
4786
4809
4787
4810
spin_unlock_irqrestore (& vha -> hw -> tgt .sess_lock , flags );
4788
4811
@@ -4803,11 +4826,39 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
4803
4826
/* Base iIDMA settings on HBA port speed. */
4804
4827
fcport -> fp_speed = ha -> link_data_rate ;
4805
4828
4806
- qla2x00_update_fcport (vha , fcport );
4807
-
4808
4829
found_devs ++ ;
4809
4830
}
4810
4831
4832
+ list_for_each_entry (fcport , & vha -> vp_fcports , list ) {
4833
+ if (test_bit (LOOP_RESYNC_NEEDED , & vha -> dpc_flags ))
4834
+ break ;
4835
+
4836
+ if (fcport -> scan_state == QLA_FCPORT_SCAN ) {
4837
+ if ((qla_dual_mode_enabled (vha ) ||
4838
+ qla_ini_mode_enabled (vha )) &&
4839
+ atomic_read (& fcport -> state ) == FCS_ONLINE ) {
4840
+ qla2x00_mark_device_lost (vha , fcport ,
4841
+ ql2xplogiabsentdevice , 0 );
4842
+ if (fcport -> loop_id != FC_NO_LOOP_ID &&
4843
+ (fcport -> flags & FCF_FCP2_DEVICE ) == 0 &&
4844
+ fcport -> port_type != FCT_INITIATOR &&
4845
+ fcport -> port_type != FCT_BROADCAST ) {
4846
+ ql_dbg (ql_dbg_disc , vha , 0x20f0 ,
4847
+ "%s %d %8phC post del sess\n" ,
4848
+ __func__ , __LINE__ ,
4849
+ fcport -> port_name );
4850
+
4851
+ qlt_schedule_sess_for_deletion_lock
4852
+ (fcport );
4853
+ continue ;
4854
+ }
4855
+ }
4856
+ }
4857
+
4858
+ if (fcport -> scan_state == QLA_FCPORT_FOUND )
4859
+ qla24xx_fcport_handle_login (vha , fcport );
4860
+ }
4861
+
4811
4862
cleanup_allocation :
4812
4863
kfree (new_fcport );
4813
4864
@@ -6115,6 +6166,8 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha)
6115
6166
if (!(IS_P3P_TYPE (ha )))
6116
6167
ha -> isp_ops -> reset_chip (vha );
6117
6168
6169
+ SAVE_TOPO (ha );
6170
+ ha -> flags .rida_fmt2 = 0 ;
6118
6171
ha -> flags .n2n_ae = 0 ;
6119
6172
ha -> flags .lip_ae = 0 ;
6120
6173
ha -> current_topology = 0 ;
0 commit comments