2013-09-14 15:29:06 +00:00
|
|
|
/*-
|
2017-11-27 14:52:40 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
|
|
*
|
2013-09-14 15:29:06 +00:00
|
|
|
* Copyright (c) 2012 The FreeBSD Foundation
|
|
|
|
*
|
|
|
|
* This software was developed by Edward Tomasz Napierala under sponsorship
|
|
|
|
* from the FreeBSD Foundation.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ISCSI_H
|
|
|
|
#define ISCSI_H
|
|
|
|
|
|
|
|
struct iscsi_softc;
|
|
|
|
struct icl_conn;
|
|
|
|
|
|
|
|
#define ISCSI_NAME_LEN 224 /* 223 bytes, by RFC 3720, + '\0' */
|
|
|
|
#define ISCSI_ADDR_LEN 47 /* INET6_ADDRSTRLEN + '\0' */
|
|
|
|
#define ISCSI_SECRET_LEN 17 /* 16 + '\0' */
|
|
|
|
|
|
|
|
struct iscsi_outstanding {
|
|
|
|
TAILQ_ENTRY(iscsi_outstanding) io_next;
|
|
|
|
union ccb *io_ccb;
|
|
|
|
size_t io_received;
|
|
|
|
uint32_t io_initiator_task_tag;
|
|
|
|
uint32_t io_datasn;
|
2015-02-08 19:15:14 +00:00
|
|
|
void *io_icl_prv;
|
2013-09-14 15:29:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct iscsi_session {
|
|
|
|
TAILQ_ENTRY(iscsi_session) is_next;
|
|
|
|
|
|
|
|
struct icl_conn *is_conn;
|
|
|
|
struct mtx is_lock;
|
|
|
|
|
|
|
|
uint32_t is_statsn;
|
|
|
|
uint32_t is_cmdsn;
|
|
|
|
uint32_t is_expcmdsn;
|
|
|
|
uint32_t is_maxcmdsn;
|
|
|
|
uint32_t is_initiator_task_tag;
|
2020-10-22 20:26:27 +00:00
|
|
|
int is_protocol_level;
|
2013-09-14 15:29:06 +00:00
|
|
|
int is_initial_r2t;
|
2016-08-25 05:22:53 +00:00
|
|
|
int is_max_burst_length;
|
|
|
|
int is_first_burst_length;
|
2013-09-14 15:29:06 +00:00
|
|
|
uint8_t is_isid[6];
|
2014-07-06 17:37:49 +00:00
|
|
|
uint16_t is_tsih;
|
2013-09-14 15:29:06 +00:00
|
|
|
bool is_immediate_data;
|
2016-08-25 05:22:53 +00:00
|
|
|
int is_max_recv_data_segment_length;
|
|
|
|
int is_max_send_data_segment_length;
|
2013-09-14 15:29:06 +00:00
|
|
|
char is_target_alias[ISCSI_ALIAS_LEN];
|
|
|
|
|
|
|
|
TAILQ_HEAD(, iscsi_outstanding) is_outstanding;
|
2014-04-04 08:43:23 +00:00
|
|
|
STAILQ_HEAD(, icl_pdu) is_postponed;
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
|
|
struct callout is_callout;
|
|
|
|
unsigned int is_timeout;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX: This could be rewritten using a single variable,
|
|
|
|
* but somehow it results in uglier code.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* We're waiting for iscsid(8); after iscsid_timeout
|
|
|
|
* expires, kernel will wake up an iscsid(8) to handle
|
|
|
|
* the session.
|
|
|
|
*/
|
|
|
|
bool is_waiting_for_iscsid;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some iscsid(8) instance is handling the session;
|
|
|
|
* after login_timeout expires, kernel will wake up
|
|
|
|
* another iscsid(8) to handle the session.
|
|
|
|
*/
|
|
|
|
bool is_login_phase;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We're in the process of removing the iSCSI session.
|
|
|
|
*/
|
|
|
|
bool is_terminating;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We're waiting for the maintenance thread to do some
|
|
|
|
* reconnection tasks.
|
|
|
|
*/
|
|
|
|
bool is_reconnecting;
|
|
|
|
|
|
|
|
bool is_connected;
|
|
|
|
|
|
|
|
struct cam_devq *is_devq;
|
|
|
|
struct cam_sim *is_sim;
|
|
|
|
struct cam_path *is_path;
|
|
|
|
struct cv is_maintenance_cv;
|
|
|
|
struct iscsi_softc *is_softc;
|
|
|
|
unsigned int is_id;
|
|
|
|
struct iscsi_session_conf is_conf;
|
|
|
|
bool is_simq_frozen;
|
|
|
|
|
|
|
|
char is_reason[ISCSI_REASON_LEN];
|
|
|
|
|
|
|
|
#ifdef ICL_KERNEL_PROXY
|
2016-02-10 17:55:39 +00:00
|
|
|
struct cv is_login_cv;
|
2013-09-14 15:29:06 +00:00
|
|
|
struct icl_pdu *is_login_pdu;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
struct iscsi_softc {
|
|
|
|
device_t sc_dev;
|
|
|
|
struct sx sc_lock;
|
|
|
|
struct cdev *sc_cdev;
|
|
|
|
TAILQ_HEAD(, iscsi_session) sc_sessions;
|
|
|
|
struct cv sc_cv;
|
|
|
|
unsigned int sc_last_session_id;
|
2016-01-11 10:24:30 +00:00
|
|
|
eventhandler_tag sc_shutdown_pre_eh;
|
|
|
|
eventhandler_tag sc_shutdown_post_eh;
|
2013-09-14 15:29:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* !ISCSI_H */
|