forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/drivers/scsi/be2iscsi/be_iscsi.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * This file is part of the Emulex Linux Device Driver for Enterprise iSCSI
34 * Host Bus Adapters. Refer to the README file included with this package
....@@ -6,13 +7,8 @@
67 * Copyright (c) 2018 Broadcom. All Rights Reserved.
78 * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
89 *
9
- * This program is free software; you can redistribute it and/or modify it
10
- * under the terms of version 2 of the GNU General Public License as published
11
- * by the Free Software Foundation.
12
- *
1310 * Contact Information:
1411 * linux-drivers@broadcom.com
15
- *
1612 */
1713
1814 #include <scsi/libiscsi.h>
....@@ -31,6 +27,7 @@
3127
3228 /**
3329 * beiscsi_session_create - creates a new iscsi session
30
+ * @ep: pointer to iscsi ep
3431 * @cmds_max: max commands supported
3532 * @qdepth: max queue depth supported
3633 * @initial_cmdsn: initial iscsi CMDSN
....@@ -168,6 +165,7 @@
168165 * @cls_session: pointer to iscsi cls session
169166 * @cls_conn: pointer to iscsi cls conn
170167 * @transport_fd: EP handle(64 bit)
168
+ * @is_leading: indicate if this is the session leading connection (MCS)
171169 *
172170 * This function binds the TCP Conn with iSCSI Connection and Session.
173171 */
....@@ -184,6 +182,7 @@
184182 struct beiscsi_endpoint *beiscsi_ep;
185183 struct iscsi_endpoint *ep;
186184 uint16_t cri_index;
185
+ int rc = 0;
187186
188187 ep = iscsi_lookup_endpoint(transport_fd);
189188 if (!ep)
....@@ -191,15 +190,17 @@
191190
192191 beiscsi_ep = ep->dd_data;
193192
194
- if (iscsi_conn_bind(cls_session, cls_conn, is_leading))
195
- return -EINVAL;
193
+ if (iscsi_conn_bind(cls_session, cls_conn, is_leading)) {
194
+ rc = -EINVAL;
195
+ goto put_ep;
196
+ }
196197
197198 if (beiscsi_ep->phba != phba) {
198199 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
199200 "BS_%d : beiscsi_ep->hba=%p not equal to phba=%p\n",
200201 beiscsi_ep->phba, phba);
201
-
202
- return -EEXIST;
202
+ rc = -EEXIST;
203
+ goto put_ep;
203204 }
204205 cri_index = BE_GET_CRI_FROM_CID(beiscsi_ep->ep_cid);
205206 if (phba->conn_table[cri_index]) {
....@@ -211,7 +212,8 @@
211212 beiscsi_ep->ep_cid,
212213 beiscsi_conn,
213214 phba->conn_table[cri_index]);
214
- return -EINVAL;
215
+ rc = -EINVAL;
216
+ goto put_ep;
215217 }
216218 }
217219
....@@ -228,7 +230,10 @@
228230 "BS_%d : cid %d phba->conn_table[%u]=%p\n",
229231 beiscsi_ep->ep_cid, cri_index, beiscsi_conn);
230232 phba->conn_table[cri_index] = beiscsi_conn;
231
- return 0;
233
+
234
+put_ep:
235
+ iscsi_put_endpoint(ep);
236
+ return rc;
232237 }
233238
234239 static int beiscsi_iface_create_ipv4(struct beiscsi_hba *phba)
....@@ -679,6 +684,7 @@
679684 case ISCSI_PARAM_MAX_XMIT_DLENGTH:
680685 if (conn->max_xmit_dlength > 65536)
681686 conn->max_xmit_dlength = 65536;
687
+ fallthrough;
682688 default:
683689 return 0;
684690 }
....@@ -771,7 +777,7 @@
771777 status = beiscsi_get_initiator_name(phba, buf, false);
772778 if (status < 0) {
773779 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
774
- "BS_%d : Retreiving Initiator Name Failed\n");
780
+ "BS_%d : Retrieving Initiator Name Failed\n");
775781 status = 0;
776782 }
777783 }
....@@ -995,7 +1001,7 @@
9951001
9961002 /**
9971003 * beiscsi_free_ep - free endpoint
998
- * @ep: pointer to iscsi endpoint structure
1004
+ * @beiscsi_ep: pointer to device endpoint struct
9991005 */
10001006 static void beiscsi_free_ep(struct beiscsi_endpoint *beiscsi_ep)
10011007 {
....@@ -1030,9 +1036,10 @@
10301036
10311037 /**
10321038 * beiscsi_open_conn - Ask FW to open a TCP connection
1033
- * @ep: endpoint to be used
1039
+ * @ep: pointer to device endpoint struct
10341040 * @src_addr: The source IP address
10351041 * @dst_addr: The Destination IP address
1042
+ * @non_blocking: blocking or non-blocking call
10361043 *
10371044 * Asks the FW to open a TCP connection
10381045 */
....@@ -1071,9 +1078,9 @@
10711078 else
10721079 req_memsize = sizeof(struct tcp_connect_and_offload_in_v1);
10731080
1074
- nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev,
1081
+ nonemb_cmd.va = dma_alloc_coherent(&phba->ctrl.pdev->dev,
10751082 req_memsize,
1076
- &nonemb_cmd.dma);
1083
+ &nonemb_cmd.dma, GFP_KERNEL);
10771084 if (nonemb_cmd.va == NULL) {
10781085
10791086 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
....@@ -1091,7 +1098,7 @@
10911098 "BS_%d : mgmt_open_connection Failed for cid=%d\n",
10921099 beiscsi_ep->ep_cid);
10931100
1094
- pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
1101
+ dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
10951102 nonemb_cmd.va, nonemb_cmd.dma);
10961103 beiscsi_free_ep(beiscsi_ep);
10971104 return -EAGAIN;
....@@ -1104,8 +1111,9 @@
11041111 "BS_%d : mgmt_open_connection Failed");
11051112
11061113 if (ret != -EBUSY)
1107
- pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
1108
- nonemb_cmd.va, nonemb_cmd.dma);
1114
+ dma_free_coherent(&phba->ctrl.pdev->dev,
1115
+ nonemb_cmd.size, nonemb_cmd.va,
1116
+ nonemb_cmd.dma);
11091117
11101118 beiscsi_free_ep(beiscsi_ep);
11111119 return ret;
....@@ -1118,14 +1126,14 @@
11181126 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
11191127 "BS_%d : mgmt_open_connection Success\n");
11201128
1121
- pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
1129
+ dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
11221130 nonemb_cmd.va, nonemb_cmd.dma);
11231131 return 0;
11241132 }
11251133
11261134 /**
11271135 * beiscsi_ep_connect - Ask chip to create TCP Conn
1128
- * @scsi_host: Pointer to scsi_host structure
1136
+ * @shost: Pointer to scsi_host structure
11291137 * @dst_addr: The IP address of Target
11301138 * @non_blocking: blocking or non-blocking call
11311139 *
....@@ -1230,7 +1238,7 @@
12301238
12311239 /**
12321240 * beiscsi_conn_close - Invalidate and upload connection
1233
- * @ep: The iscsi endpoint
1241
+ * @beiscsi_ep: pointer to device endpoint struct
12341242 *
12351243 * Returns 0 on success, -1 on failure.
12361244 */