| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * iSCSI transport class definitions |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * Copyright (C) Mike Christie, 2004 - 2006 |
|---|
| 6 | 7 | * Copyright (C) Dmitry Yusupov, 2004 - 2005 |
|---|
| 7 | 8 | * 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. |
|---|
| 22 | 9 | */ |
|---|
| 23 | 10 | #ifndef SCSI_TRANSPORT_ISCSI_H |
|---|
| 24 | 11 | #define SCSI_TRANSPORT_ISCSI_H |
|---|
| .. | .. |
|---|
| 70 | 57 | * When not offloading the data path, this is called |
|---|
| 71 | 58 | * from the scsi work queue without the session lock. |
|---|
| 72 | 59 | * @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 |
|---|
| 74 | 61 | * value on error. When offloading the data path, this |
|---|
| 75 | 62 | * is called from queuecommand with the session lock, or |
|---|
| 76 | 63 | * from the iscsi_conn_send_pdu context with the session |
|---|
| .. | .. |
|---|
| 95 | 82 | void (*destroy_session) (struct iscsi_cls_session *session); |
|---|
| 96 | 83 | struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess, |
|---|
| 97 | 84 | uint32_t cid); |
|---|
| 85 | + void (*unbind_conn) (struct iscsi_cls_conn *conn, bool is_active); |
|---|
| 98 | 86 | int (*bind_conn) (struct iscsi_cls_session *session, |
|---|
| 99 | 87 | struct iscsi_cls_conn *cls_conn, |
|---|
| 100 | 88 | uint64_t transport_eph, int is_leading); |
|---|
| .. | .. |
|---|
| 201 | 189 | uint32_t status, uint32_t pid, |
|---|
| 202 | 190 | uint32_t data_size, uint8_t *data); |
|---|
| 203 | 191 | |
|---|
| 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 | + |
|---|
| 204 | 202 | struct iscsi_cls_conn { |
|---|
| 205 | 203 | struct list_head conn_list; /* item in connlist */ |
|---|
| 206 | 204 | void *dd_data; /* LLD private data */ |
|---|
| 207 | 205 | struct iscsi_transport *transport; |
|---|
| 208 | 206 | 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 | + */ |
|---|
| 209 | 211 | struct mutex ep_mutex; |
|---|
| 210 | 212 | struct iscsi_endpoint *ep; |
|---|
| 211 | 213 | |
|---|
| 214 | + /* Used when accessing flags and queueing work. */ |
|---|
| 215 | + spinlock_t lock; |
|---|
| 216 | + unsigned long flags; |
|---|
| 217 | + struct work_struct cleanup_work; |
|---|
| 218 | + |
|---|
| 212 | 219 | struct device dev; /* sysfs transport/container device */ |
|---|
| 220 | + enum iscsi_connection_state state; |
|---|
| 213 | 221 | }; |
|---|
| 214 | 222 | |
|---|
| 215 | 223 | #define iscsi_dev_to_conn(_dev) \ |
|---|
| .. | .. |
|---|
| 228 | 236 | ISCSI_SESSION_FREE, |
|---|
| 229 | 237 | }; |
|---|
| 230 | 238 | |
|---|
| 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 | + |
|---|
| 231 | 247 | #define ISCSI_MAX_TARGET -1 |
|---|
| 232 | 248 | |
|---|
| 233 | 249 | struct iscsi_cls_session { |
|---|
| .. | .. |
|---|
| 238 | 254 | struct work_struct unblock_work; |
|---|
| 239 | 255 | struct work_struct scan_work; |
|---|
| 240 | 256 | struct work_struct unbind_work; |
|---|
| 257 | + struct work_struct destroy_work; |
|---|
| 241 | 258 | |
|---|
| 242 | 259 | /* recovery fields */ |
|---|
| 243 | 260 | int recovery_tmo; |
|---|
| .. | .. |
|---|
| 253 | 270 | */ |
|---|
| 254 | 271 | pid_t creator; |
|---|
| 255 | 272 | int state; |
|---|
| 273 | + int target_state; /* session target bind state */ |
|---|
| 256 | 274 | int sid; /* session id */ |
|---|
| 257 | 275 | void *dd_data; /* LLD private data */ |
|---|
| 258 | 276 | struct device dev; /* sysfs transport/container device */ |
|---|
| .. | .. |
|---|
| 445 | 463 | extern struct iscsi_endpoint *iscsi_create_endpoint(int dd_size); |
|---|
| 446 | 464 | extern void iscsi_destroy_endpoint(struct iscsi_endpoint *ep); |
|---|
| 447 | 465 | extern struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle); |
|---|
| 466 | +extern void iscsi_put_endpoint(struct iscsi_endpoint *ep); |
|---|
| 448 | 467 | extern int iscsi_block_scsi_eh(struct scsi_cmnd *cmd); |
|---|
| 449 | 468 | extern struct iscsi_iface *iscsi_create_iface(struct Scsi_Host *shost, |
|---|
| 450 | 469 | struct iscsi_transport *t, |
|---|