forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/scsi/libfc/fc_rport.c
....@@ -1,18 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright(c) 2007 - 2008 Intel Corporation. All rights reserved.
3
- *
4
- * This program is free software; you can redistribute it and/or modify it
5
- * under the terms and conditions of the GNU General Public License,
6
- * version 2, as published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope it will be useful, but WITHOUT
9
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11
- * more details.
12
- *
13
- * You should have received a copy of the GNU General Public License along with
14
- * this program; if not, write to the Free Software Foundation, Inc.,
15
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
164 *
175 * Maintained at www.Open-FCoE.org
186 */
....@@ -133,7 +121,7 @@
133121 /**
134122 * fc_rport_create() - Create a new remote port
135123 * @lport: The local port this remote port will be associated with
136
- * @ids: The identifiers for the new remote port
124
+ * @port_id: The identifiers for the new remote port
137125 *
138126 * The remote port will start in the INIT state.
139127 */
....@@ -647,6 +635,8 @@
647635 fc_rport_enter_ready(rdata);
648636 break;
649637 case RPORT_ST_PRLI:
638
+ fc_rport_enter_plogi(rdata);
639
+ break;
650640 case RPORT_ST_ADISC:
651641 fc_rport_enter_logo(rdata);
652642 break;
....@@ -865,7 +855,6 @@
865855 static void fc_rport_recv_flogi_req(struct fc_lport *lport,
866856 struct fc_frame *rx_fp)
867857 {
868
- struct fc_disc *disc;
869858 struct fc_els_flogi *flp;
870859 struct fc_rport_priv *rdata;
871860 struct fc_frame *fp = rx_fp;
....@@ -876,7 +865,6 @@
876865
877866 FC_RPORT_ID_DBG(lport, sid, "Received FLOGI request\n");
878867
879
- disc = &lport->disc;
880868 if (!lport->point_to_multipoint) {
881869 rjt_data.reason = ELS_RJT_UNSUP;
882870 rjt_data.explan = ELS_EXPL_NONE;
....@@ -1043,8 +1031,11 @@
10431031 struct fc_els_ls_rjt *rjt;
10441032
10451033 rjt = fc_frame_payload_get(fp, sizeof(*rjt));
1046
- FC_RPORT_DBG(rdata, "PLOGI ELS rejected, reason %x expl %x\n",
1047
- rjt->er_reason, rjt->er_explan);
1034
+ if (!rjt)
1035
+ FC_RPORT_DBG(rdata, "PLOGI bad response\n");
1036
+ else
1037
+ FC_RPORT_DBG(rdata, "PLOGI ELS rejected, reason %x expl %x\n",
1038
+ rjt->er_reason, rjt->er_explan);
10481039 fc_rport_error_retry(rdata, -FC_EX_ELS_RJT);
10491040 }
10501041 out:
....@@ -1163,8 +1154,10 @@
11631154 op = fc_frame_payload_op(fp);
11641155 if (op == ELS_LS_ACC) {
11651156 pp = fc_frame_payload_get(fp, sizeof(*pp));
1166
- if (!pp)
1157
+ if (!pp) {
1158
+ fc_rport_error_retry(rdata, -FC_EX_SEQ_ERR);
11671159 goto out;
1160
+ }
11681161
11691162 resp_code = (pp->spp.spp_flags & FC_SPP_RESP_MASK);
11701163 FC_RPORT_DBG(rdata, "PRLI spp_flags = 0x%x spp_type 0x%x\n",
....@@ -1178,8 +1171,10 @@
11781171 fc_rport_error_retry(rdata, -FC_EX_SEQ_ERR);
11791172 goto out;
11801173 }
1181
- if (pp->prli.prli_spp_len < sizeof(pp->spp))
1174
+ if (pp->prli.prli_spp_len < sizeof(pp->spp)) {
1175
+ fc_rport_error_retry(rdata, -FC_EX_SEQ_ERR);
11821176 goto out;
1177
+ }
11831178
11841179 fcp_parm = ntohl(pp->spp.spp_params);
11851180 if (fcp_parm & FCP_SPPF_RETRY)
....@@ -1219,8 +1214,17 @@
12191214
12201215 } else {
12211216 rjt = fc_frame_payload_get(fp, sizeof(*rjt));
1222
- FC_RPORT_DBG(rdata, "PRLI ELS rejected, reason %x expl %x\n",
1223
- rjt->er_reason, rjt->er_explan);
1217
+ if (!rjt)
1218
+ FC_RPORT_DBG(rdata, "PRLI bad response\n");
1219
+ else {
1220
+ FC_RPORT_DBG(rdata, "PRLI ELS rejected, reason %x expl %x\n",
1221
+ rjt->er_reason, rjt->er_explan);
1222
+ if (rjt->er_reason == ELS_RJT_UNAB &&
1223
+ rjt->er_explan == ELS_EXPL_PLOGI_REQD) {
1224
+ fc_rport_enter_plogi(rdata);
1225
+ goto out;
1226
+ }
1227
+ }
12241228 fc_rport_error_retry(rdata, FC_EX_ELS_RJT);
12251229 }
12261230
....@@ -1444,7 +1448,7 @@
14441448 * fc_rport_logo_resp() - Handler for logout (LOGO) responses
14451449 * @sp: The sequence the LOGO was on
14461450 * @fp: The LOGO response frame
1447
- * @lport_arg: The local port
1451
+ * @rdata_arg: The remote port
14481452 */
14491453 static void fc_rport_logo_resp(struct fc_seq *sp, struct fc_frame *fp,
14501454 void *rdata_arg)
....@@ -1722,6 +1726,7 @@
17221726 kref_put(&rdata->kref, fc_rport_destroy);
17231727 goto busy;
17241728 }
1729
+ fallthrough;
17251730 default:
17261731 FC_RPORT_DBG(rdata,
17271732 "Reject ELS 0x%02x while in state %s\n",