hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
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)
....@@ -445,6 +450,10 @@
445450 }
446451
447452 nla_for_each_attr(attrib, data, dt_len, rm_len) {
453
+ /* ignore nla_type as it is never used */
454
+ if (nla_len(attrib) < sizeof(*iface_param))
455
+ return -EINVAL;
456
+
448457 iface_param = nla_data(attrib);
449458
450459 if (iface_param->param_type != ISCSI_NET_PARAM)
....@@ -679,6 +688,7 @@
679688 case ISCSI_PARAM_MAX_XMIT_DLENGTH:
680689 if (conn->max_xmit_dlength > 65536)
681690 conn->max_xmit_dlength = 65536;
691
+ fallthrough;
682692 default:
683693 return 0;
684694 }
....@@ -771,7 +781,7 @@
771781 status = beiscsi_get_initiator_name(phba, buf, false);
772782 if (status < 0) {
773783 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
774
- "BS_%d : Retreiving Initiator Name Failed\n");
784
+ "BS_%d : Retrieving Initiator Name Failed\n");
775785 status = 0;
776786 }
777787 }
....@@ -995,7 +1005,7 @@
9951005
9961006 /**
9971007 * beiscsi_free_ep - free endpoint
998
- * @ep: pointer to iscsi endpoint structure
1008
+ * @beiscsi_ep: pointer to device endpoint struct
9991009 */
10001010 static void beiscsi_free_ep(struct beiscsi_endpoint *beiscsi_ep)
10011011 {
....@@ -1030,9 +1040,10 @@
10301040
10311041 /**
10321042 * beiscsi_open_conn - Ask FW to open a TCP connection
1033
- * @ep: endpoint to be used
1043
+ * @ep: pointer to device endpoint struct
10341044 * @src_addr: The source IP address
10351045 * @dst_addr: The Destination IP address
1046
+ * @non_blocking: blocking or non-blocking call
10361047 *
10371048 * Asks the FW to open a TCP connection
10381049 */
....@@ -1071,9 +1082,9 @@
10711082 else
10721083 req_memsize = sizeof(struct tcp_connect_and_offload_in_v1);
10731084
1074
- nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev,
1085
+ nonemb_cmd.va = dma_alloc_coherent(&phba->ctrl.pdev->dev,
10751086 req_memsize,
1076
- &nonemb_cmd.dma);
1087
+ &nonemb_cmd.dma, GFP_KERNEL);
10771088 if (nonemb_cmd.va == NULL) {
10781089
10791090 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_CONFIG,
....@@ -1091,7 +1102,7 @@
10911102 "BS_%d : mgmt_open_connection Failed for cid=%d\n",
10921103 beiscsi_ep->ep_cid);
10931104
1094
- pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
1105
+ dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
10951106 nonemb_cmd.va, nonemb_cmd.dma);
10961107 beiscsi_free_ep(beiscsi_ep);
10971108 return -EAGAIN;
....@@ -1104,8 +1115,9 @@
11041115 "BS_%d : mgmt_open_connection Failed");
11051116
11061117 if (ret != -EBUSY)
1107
- pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
1108
- nonemb_cmd.va, nonemb_cmd.dma);
1118
+ dma_free_coherent(&phba->ctrl.pdev->dev,
1119
+ nonemb_cmd.size, nonemb_cmd.va,
1120
+ nonemb_cmd.dma);
11091121
11101122 beiscsi_free_ep(beiscsi_ep);
11111123 return ret;
....@@ -1118,14 +1130,14 @@
11181130 beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
11191131 "BS_%d : mgmt_open_connection Success\n");
11201132
1121
- pci_free_consistent(phba->ctrl.pdev, nonemb_cmd.size,
1133
+ dma_free_coherent(&phba->ctrl.pdev->dev, nonemb_cmd.size,
11221134 nonemb_cmd.va, nonemb_cmd.dma);
11231135 return 0;
11241136 }
11251137
11261138 /**
11271139 * beiscsi_ep_connect - Ask chip to create TCP Conn
1128
- * @scsi_host: Pointer to scsi_host structure
1140
+ * @shost: Pointer to scsi_host structure
11291141 * @dst_addr: The IP address of Target
11301142 * @non_blocking: blocking or non-blocking call
11311143 *
....@@ -1230,7 +1242,7 @@
12301242
12311243 /**
12321244 * beiscsi_conn_close - Invalidate and upload connection
1233
- * @ep: The iscsi endpoint
1245
+ * @beiscsi_ep: pointer to device endpoint struct
12341246 *
12351247 * Returns 0 on success, -1 on failure.
12361248 */