hc
2024-01-31 f9004dbfff8a3fbbd7e2a88c8a4327c7f2f8e5b2
kernel/include/scsi/scsi_transport_iscsi.h
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * iSCSI transport class definitions
34 *
....@@ -5,20 +6,6 @@
56 * Copyright (C) Mike Christie, 2004 - 2006
67 * Copyright (C) Dmitry Yusupov, 2004 - 2005
78 * Copyright (C) Alex Aizman, 2004 - 2005
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- * GNU General Public License for more details.
18
- *
19
- * You should have received a copy of the GNU General Public License
20
- * along with this program; if not, write to the Free Software
21
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
229 */
2310 #ifndef SCSI_TRANSPORT_ISCSI_H
2411 #define SCSI_TRANSPORT_ISCSI_H
....@@ -70,7 +57,7 @@
7057 * When not offloading the data path, this is called
7158 * from the scsi work queue without the session lock.
7259 * @xmit_task Requests LLD to transfer cmd task. Returns 0 or the
73
- * the number of bytes transferred on success, and -Exyz
60
+ * number of bytes transferred on success, and -Exyz
7461 * value on error. When offloading the data path, this
7562 * is called from queuecommand with the session lock, or
7663 * from the iscsi_conn_send_pdu context with the session
....@@ -95,6 +82,7 @@
9582 void (*destroy_session) (struct iscsi_cls_session *session);
9683 struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess,
9784 uint32_t cid);
85
+ void (*unbind_conn) (struct iscsi_cls_conn *conn, bool is_active);
9886 int (*bind_conn) (struct iscsi_cls_session *session,
9987 struct iscsi_cls_conn *cls_conn,
10088 uint64_t transport_eph, int is_leading);
....@@ -201,15 +189,35 @@
201189 uint32_t status, uint32_t pid,
202190 uint32_t data_size, uint8_t *data);
203191
192
+/* iscsi class connection state */
193
+enum iscsi_connection_state {
194
+ ISCSI_CONN_UP = 0,
195
+ ISCSI_CONN_DOWN,
196
+ ISCSI_CONN_FAILED,
197
+ ISCSI_CONN_BOUND,
198
+};
199
+
200
+#define ISCSI_CLS_CONN_BIT_CLEANUP 1
201
+
204202 struct iscsi_cls_conn {
205203 struct list_head conn_list; /* item in connlist */
206204 void *dd_data; /* LLD private data */
207205 struct iscsi_transport *transport;
208206 uint32_t cid; /* connection id */
207
+ /*
208
+ * This protects the conn startup and binding/unbinding of the ep to
209
+ * the conn. Unbinding includes ep_disconnect and stop_conn.
210
+ */
209211 struct mutex ep_mutex;
210212 struct iscsi_endpoint *ep;
211213
214
+ /* Used when accessing flags and queueing work. */
215
+ spinlock_t lock;
216
+ unsigned long flags;
217
+ struct work_struct cleanup_work;
218
+
212219 struct device dev; /* sysfs transport/container device */
220
+ enum iscsi_connection_state state;
213221 };
214222
215223 #define iscsi_dev_to_conn(_dev) \
....@@ -228,6 +236,14 @@
228236 ISCSI_SESSION_FREE,
229237 };
230238
239
+enum {
240
+ ISCSI_SESSION_TARGET_UNBOUND,
241
+ ISCSI_SESSION_TARGET_ALLOCATED,
242
+ ISCSI_SESSION_TARGET_SCANNED,
243
+ ISCSI_SESSION_TARGET_UNBINDING,
244
+ ISCSI_SESSION_TARGET_MAX,
245
+};
246
+
231247 #define ISCSI_MAX_TARGET -1
232248
233249 struct iscsi_cls_session {
....@@ -238,6 +254,7 @@
238254 struct work_struct unblock_work;
239255 struct work_struct scan_work;
240256 struct work_struct unbind_work;
257
+ struct work_struct destroy_work;
241258
242259 /* recovery fields */
243260 int recovery_tmo;
....@@ -253,6 +270,7 @@
253270 */
254271 pid_t creator;
255272 int state;
273
+ int target_state; /* session target bind state */
256274 int sid; /* session id */
257275 void *dd_data; /* LLD private data */
258276 struct device dev; /* sysfs transport/container device */
....@@ -445,6 +463,7 @@
445463 extern struct iscsi_endpoint *iscsi_create_endpoint(int dd_size);
446464 extern void iscsi_destroy_endpoint(struct iscsi_endpoint *ep);
447465 extern struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle);
466
+extern void iscsi_put_endpoint(struct iscsi_endpoint *ep);
448467 extern int iscsi_block_scsi_eh(struct scsi_cmnd *cmd);
449468 extern struct iscsi_iface *iscsi_create_iface(struct Scsi_Host *shost,
450469 struct iscsi_transport *t,