fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2000 by Cisco Systems, Inc. All rights reserved.
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
59927d313a821b7f3822314ed16fc0a44c128431Yuri Pankov * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Block comment which describes the contents of this file.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define LOGIN_PDU_BUFFER_SIZE (16 * 1024) /* move somewhere else */
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#define ISCSI_CONN_LOG if (iscsi_conn_logging) cmn_err
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#define ISCSI_IO_LOG if (iscsi_io_logging) cmn_err
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#define ISCSI_LOGIN_LOG if (iscsi_login_logging) cmn_err
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#define ISCSI_SESS_LOG if (iscsi_sess_logging) cmn_err
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Name Format of the different Task Queues
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SESS_IOTH_NAME_FORMAT "io_thrd_%d.%d"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SESS_LOGIN_TASKQ_NAME_FORMAT "login_taskq_%d.%d"
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng#define ISCSI_SESS_ENUM_TASKQ_NAME_FORMAT "enum_taskq_%d.%d"
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#define ISCSI_CONN_CN_TASKQ_NAME_FORMAT "conn_cn_taskq_%d.%d.%d"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_CONN_RXTH_NAME_FORMAT "rx_thrd_%d.%d.%d"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_CONN_TXTH_NAME_FORMAT "tx_thrd_%d.%d.%d"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The iSCSI driver will not build scatter/gather lists (iovec) longer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * than the value defined here. Asserts have been include in the code
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The SNDBUF and RCVBUF size parameters for the sockets are just a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * guess for the time being (I think it is the values used by CISCO
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or UNH). Testing will have to be done to figure * out the impact
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of these values on performance.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_TCP_ABORT_THRESHOLD_DEFAULT (30 * 1000) /* milliseconds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISNS_TCP_ABORT_THRESHOLD_DEFAULT (3 * 1000) /* milliseconds */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China/* Default values for tunable parameters */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China#define ISCSI_DEFAULT_RX_TIMEOUT_VALUE 60
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China#define ISCSI_DEFAULT_CONN_DEFAULT_LOGIN_MAX 180
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China#define ISCSI_DEFAULT_LOGIN_POLLING_DELAY 60
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Convenient short hand defines
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SENDTARGETS_DISCOVERY "SENDTARGETS_DISCOVERY"
b97c1f925a1d211d325cdc3a2e4b3b779082510bMilos Muzik#define ISCSI_LUN_MASK (ISCSI_LUN_MASK_MSB | ISCSI_LUN_MASK_LSB)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_LUN_BYTE_COPY(lun, report_lun_data) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lun[0] = (report_lun_data & ISCSI_LUN_MASK_MSB) >> 8; \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Not defined by iSCSI, but used in the login code to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * determine when to send the initial Login PDU
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Success */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Driver / Kernel / Code error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ITT table is already full, unable to reserve slot */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Login on connection failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No connections are in the LOGGED_IN state */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* TCP Transfer Error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* TCP Receive Error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI packet RCV timeout */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI Header Digest CRC error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI Data Digest CRC error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* kmem_alloc failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cmd (tran_abort/reset) failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI protocol error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI protocol version mismatch */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI login negotiation failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI login authentication failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI login redirection failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI uscsi status failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* data received would have overflowed given buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* session/connection needs to shutdown */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* logical unit in use */
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap /* Login on connection failed, retries exceeded */
cc7ef4959916befd1d1197845b5b82284d96c450yi zhang - Sun Microsystems - Beijing China ISCSI_STATUS_LOGIN_TIMED_OUT,
cc7ef4959916befd1d1197845b5b82284d96c450yi zhang - Sun Microsystems - Beijing China /* iSCSI login tpgt negotiation failed */
cc7ef4959916befd1d1197845b5b82284d96c450yi zhang - Sun Microsystems - Beijing China ISCSI_STATUS_LOGIN_TPGT_NEGO_FAIL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SUCCESS(status) (status == ISCSI_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* SNA32 check value used on increment of CmdSn values */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SNA32_CHECK 2147483648UL /* 2**31 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is the maximum number of commands that can be outstanding
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on a iSCSI session at anyone point in time.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Used on connections thread create of receiver thread */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Callers of iscsid_config_one/all must hold this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * semaphore across the calls. Otherwise a ndi_devi_enter()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * deadlock in the DDI layer may occur.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NOP delay is used to send a iSCSI NOP (ie. ping) across the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * wire to see if the target is still alive. NOPs are only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sent when the RX thread hasn't received anything for the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * below amount of time.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we haven't received anything in a specified period of time
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we will stop accepting IO via tran start. This will enable
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * upper level drivers to see we might be having a problem and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in the case of scsi_vhci will start to route IO down a better
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we haven't received anything in a specified period of time
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we will stop accepting IO via tran start. This the max limit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * when encountered we will start returning a fatal error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_DEFAULT_RX_MAX_WINDOW 180 /* seconds */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * During iscsi boot, if the boot session has been created, the
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * initiator hasn't changed the boot lun to be online, we will wait
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng * 180s here for lun online by default.
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng#define ISCSI_BOOT_DEFAULT_MAX_DELAY 180 /* seconds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * +--------------------------------------------------------------------+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * | iSCSI Driver Structures |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * +--------------------------------------------------------------------+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Auth Information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * To indicate if bi-directional authentication is enabled.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 means uni-directional authentication.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1 means bi-directional authentication.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initiator's authentication information. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Target's authentication information. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Task
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * These are all the iscsi_cmd types that we use to track our
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * commands between queues and actions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi_cmd_state - (reference iscsi_cmd.c for state diagram)
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_cmd_state_names[ISCSI_CMD_STATE_MAX+1] = {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CMD_STATE_FREE",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CMD_STATE_PENDING",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CMD_STATE_ACTIVE",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CMD_STATE_ABORTING",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CMD_STATE_IDM_ABORTING",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CMD_STATE_COMPLETED",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CMD_STATE_MAX"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi command events
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_cmd_event_names[ISCSI_CMD_EVENT_MAX+1] = {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CMD_EVENT_E1",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CMD_EVENT_E2",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CMD_EVENT_E3",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CMD_EVENT_E4",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CMD_EVENT_E6",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CMD_EVENT_E7",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CMD_EVENT_E8",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CMD_EVENT_E9",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CMD_EVENT_E10",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CMD_EVENT_MAX"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi text command stages - these stages are used by iSCSI text
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * processing to manage long resonses.
d233de7e52b23edf30b2270f51e28cda6e08a98cJack Meng * iscsi cmd misc flags - bitwise applicable
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China#define ISCSI_CMD_MISCFLAG_SENT 0x10
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China#define ISCSI_CMD_MISCFLAG_FLUSH 0x20
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China * 1/2 of a 32 bit number, used for checking CmdSN
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China#define ISCSI_CMD_SN_WRAP 0x80000000
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China#define ISCSI_CMD_PKT_STAT_INIT 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI cmd/pkt Structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISCSI_CMD_TYPE_SCSI */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If SCSI_CMD_TYPE is in ABORTING_STATE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * then the abort_icmdp field will be a pointer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the abort command chasing this one.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pointer to the r2t associated with this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * command (if any)
e790cde880fa38b13f6b938bc83aab8f9eacab06bing zhao - Sun Microsystems - Beijing China * It will be true if this command has
e790cde880fa38b13f6b938bc83aab8f9eacab06bing zhao - Sun Microsystems - Beijing China * another R2T to handle.
e790cde880fa38b13f6b938bc83aab8f9eacab06bing zhao - Sun Microsystems - Beijing China boolean_t r2t_more;
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China * It is used to record pkt_statistics temporarily.
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China uint_t pkt_stat;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISCSI_CMD_TYPE_ABORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pointer to original iscsi_cmd, for abort */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISCSI_CMD_TYPE_RESET */
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China uint8_t response;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISCSI_CMD_TYPE_NOP */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISCSI_CMD_TYPE_R2T */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISCSI_CMD_TYPE_LOGIN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISCSI_CMD_TYPE_LOGOUT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISCSI_CMD_TYPE_TEXT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If a data digest error is seem on a data pdu. This flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will get set. We don't abort the cmd immediately because
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we want to read in all the data to get it out of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stream. Once the completion for the cmd is received we
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we will abort the cmd and state no sense data was available.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Used to block and wake up caller until action is completed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is for ABORT, RESET, and PASSTHRU cmds.
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China uint32_t cmd_sn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI LUN Structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_lun *lun_next; /* next lun on this sess. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_sess *lun_sess; /* parent sess. for lun */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t lun_vid[ISCSI_INQ_VID_BUF_LEN]; /* Vendor ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t lun_pid[ISCSI_INQ_PID_BUF_LEN]; /* Product ID */
c60a6da3c3825f88388f3fba451c3dd975088f07bing zhao - Sun Microsystems - Beijing China uchar_t lun_type;
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China#define ISCSI_LUN_STATE_CLEAR 0 /* used to clear all states */
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China#define ISCSI_LUN_STATE_OFFLINE 1
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China#define ISCSI_LUN_STATE_ONLINE 2
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China#define ISCSI_LUN_STATE_INVALID 4 /* offline failed */
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China#define ISCSI_LUN_STATE_BUSY 8 /* logic unit is in reset */
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China#define ISCSI_LUN_CAP_RESET 0x01
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China#define ISCSI_SCSI_RESET_SENSE_CODE 0x29
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China/* iSCSI tunable Parameters */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing Chinatypedef struct iscsi_tunable_params {
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China int recv_login_rsp_timeout; /* range: 0 - 60*60 */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China int conn_login_max; /* range: 0 - 60*60 */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China int polling_login_delay; /* range: 0 - 60*60 */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China} iscsi_tunable_params_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SIZEOF_SOCKADDR(so) ((so)->sa_family == AF_INET ? \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct sockaddr_in) : sizeof (struct sockaddr_in6))
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlaptypedef enum {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_login_state_names[LOGIN_MAX+1] = {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "LOGIN_START",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "LOGIN_READY",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "LOGIN_ERROR",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "LOGIN_DONE",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "LOGIN_FFP",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * iscsi_conn_state
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_ics_name[ISCSI_CONN_STATE_MAX+1] = {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CONN_STATE_UNDEFINED",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CONN_STATE_FREE",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CONN_STATE_IN_LOGIN",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CONN_STATE_LOGGED_IN",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CONN_STATE_IN_LOGOUT",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CONN_STATE_FAILED",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CONN_STATE_POLLING",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_CONN_STATE_MAX"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Connection Structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_conn *conn_next; /* next conn on this sess. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_sess *conn_sess; /* parent sess. for conn. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_conn_state_t conn_state; /* cur. conn. driver state */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_conn_state_t conn_prev_state; /* prev. conn. driver state */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* protects the session state and synchronizes the state machine */
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap /* base connection information, may have been redirected */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* current connection information, may have been redirected */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The active queue contains iscsi_cmds that have already
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * been sent on this connection. Any future responses to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * these cmds require alligence to this connection. If there
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * are issues with these cmds the command may need aborted
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * depending on the command type, and must be put back into
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the session's pending queue or aborted.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* lbolt from the last receive, used for nop processing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The expstatsn is the command status sn that is expected
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * next from the target. Command status is carried on a number
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of iSCSI PDUs (ex. SCSI Cmd Response, SCSI Data IN with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * S-Bit set, ...), not all PDUs. If our expstatsn is different
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * than the received statsn. Something got out of sync we need to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* active login parameters */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Statistics */
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * These fields are used to coordinate the asynchronous IDM
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * PDU operations with the synchronous login code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * login min and max identify the amount of time
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in lbolt that iscsi_start_login() should attempt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to log into a target portal. The login will
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * delay until the min lbolt has been reached and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will end once max time has been reached. These
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * values are normally set to the default but can
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * are also altered by async commands received from
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the targetlogin.
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China /* active tunable parameters */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China iscsi_tunable_params_t conn_tunable_params;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China boolean_t conn_timeout;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * iscsi_sess_state - (reference iscsi_sess.c for state diagram)
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_sess_state_names[ISCSI_SESS_STATE_MAX+1] = {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_SESS_STATE_FREE",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_SESS_STATE_LOGGED_IN",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_SESS_STATE_FAILED",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_SESS_STATE_IN_FLUSH",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_SESS_STATE_FLUSHED",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_SESS_STATE_MAX"
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_sess_event_names[ISCSI_SESS_EVENT_MAX+1] = {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_SESS_EVENT_N1",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_SESS_EVENT_N3",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_SESS_EVENT_N5",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_SESS_EVENT_N6",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_SESS_EVENT_N7",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "ISCSI_SESS_EVENT_MAX"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Sun's initiator session ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SUN_ISID_0 0x40 /* ISID - EN format */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SUN_ISID_3 0x2A /* Sec C - 42 = Sun's EN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * defines 4-5 are the reserved values. These reserved values
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * are used as the ISID for an initiator-port in MP-API and used
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for the send targets discovery sessions. Byte 5 is overridden
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for full feature sessions. The default values of byte 5 for a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * full feature session is 0. When MS/T is enabled with more than
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one session this byte 5 will increment > 0 up to
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ISCSI_MAX_CONFIG_SESSIONS.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Session(Target) Structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* protects the session state and synchronizes the state machine */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Associated target OID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Session OID. Used by IMA, interfaces and exported as
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * TARGET_PROP which is checked by the NDI. In addition
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this is used in our tran_lun_init function.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* list of all luns relating to session */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* list of all connections relating to session */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pointer to active connection in session */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Connection ID for next connection to be added to session */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * last time any connection on this session received
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * data from the target.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sess_cmdsn_mutex protects the cmdsn and itt table/values
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Cmdsn isn't that big of a problem yet since we only have
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * one connection but in the future we will need to ensure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this locking is working so keep the sequence numbers in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sync on the wire.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We also use this lock to protect the ITT table and it's
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * values. We need to make sure someone doesn't assign
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a duplicate ITT value or cell to a command. Also we
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * need to make sure when someone is looking up an ITT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that the command is still in that correct queue location.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI command sequencing / windowing. The next
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * command to be sent via the pending queue will
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the sess_cmdsn. If the maxcmdsn is less
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * than the next cmdsn then the iSCSI window is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * closed and this command cannot be sent yet.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Most iscsi cmd responses from the target carry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a new maxcmdsn. If this new maxcmdsn is greater
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * than the sess_maxcmdsn we will update it's value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and set a timer to fire in one tick and reprocess
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the pending queue.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The expcmdsn. Is the value the target expects
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to be sent for my next cmdsn. If the expcmdsn
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and the cmdsn get out of sync this could denote
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a communication problem.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Next Initiator Task Tag (ITT) to use */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The session iscsi_cmd table is used to a fast performance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lookup of an ITT to a iscsi_cmd when we receive an iSCSI
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * PDU from the wire. To reserve a location in the sess_cmd_table
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we try the sess_itt % ISCSI_CMD_TABLE_SIZE if this cmd table
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cell is already full. Then increament the sess_itt and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * try to get the cell position again, repeat until an empty
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cell is found. Once an empty cell is found place your
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * scsi_cmd point into the cell to reserve the location. This
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * selection process should be done while holding the session's
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_cmd *sess_cmd_table[ISCSI_CMD_TABLE_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The pending queue contains all iscsi_cmds that require an
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * open MaxCmdSn window to be put on the wire and haven't
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * been placed on the wire. Once placed on the wire they
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will be moved to a connections specific active queue.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* configured login parameters */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* general iSCSI protocol/session info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t sess_isid[ISCSI_ISID_LEN]; /* Session ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the target portal group tag(TPGT) is equal to ISCSI_DEFAULT_TPGT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * then the initiator will accept a successful login with any TPGT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified by the target. If a none default TPGT is configured
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * then we will only successfully accept a login with that matching
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * TPGT value.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This field records the negotiated TPGT value, preserved for dtrace */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Authentication information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * DCW: Again IMA seems to take a session view at this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Statistics */
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China kmutex_t sess_reset_mutex;
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China boolean_t sess_reset_in_progress;
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng /* to accelerate the state change in case of new event */
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China * This structure will be used to store sessions to be online
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China * during normal login operation.
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing Chinatypedef struct iscsi_sess_list {
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China iscsi_sess_t *session;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China struct iscsi_sess_list *next;
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China} iscsi_sess_list_t;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * iSCSI client notify task context for deferred IDM notifications processing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi_network
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int (*bind)(void *, struct sockaddr *, int, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int (*connect)(void *, struct sockaddr *, int, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void* (*accept)(void *, struct sockaddr *, int *);
0f1702c5201310f0529cd5abb77652e5e9b241b6Yu Xiangning int (*getsockname)(void *, struct sockaddr *, socklen_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int (*getsockopt)(void *, int, int, void *, int *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int (*setsockopt)(void *, int, int, void *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_status_t (*sendpdu)(void *, iscsi_hdr_t *, char *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_status_t (*recvdata)(void *, iscsi_hdr_t *, char *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_status_t (*recvhdr)(void *, iscsi_hdr_t *, int, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we get bus_config requests in less than 5 seconds
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * apart skip the name services re-discovery and just
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * complete the requested logins. This protects against
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bus_config storms from stale /dev links.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI HBA Structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_sess *hba_sess_list; /* sess. list for hba */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte krwlock_t hba_sess_list_rwlock; /* protect sess. list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* lbolt of the last time we received a config request */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* current number of seconds to protect against bus config storms */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* general iSCSI protocol hba/initiator info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Default SessionID for HBA */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Default HBA wide settings */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * There's only one HBA and it's set to ISCSI_INITIATOR_OID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * (value of 1) at the beginning of time.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Keep track of which events have been sent. User daemons request
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this information so they don't wait for events which they won't
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng /* if the persistent store is loaded */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Ensures only one SendTargets operation occurs at a time
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Statistics
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * track/control the service status and client
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * service- service online ensures the operational of cli
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * - and the availability of iSCSI discovery/devices
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * - so obviously offline means the unusable of cli
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * - , disabling of all discovery methods and to offline
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * - all discovered devices
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * client - here the client actually means 'exclusive client'
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * - for operations these clients take may conflict
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * - with the changing of service status and therefore
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * - need to be exclusive
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * The service has three status:
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * ISCSI_SERVICE_ENABLED - client is permitted to
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * - request service
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * ISCSI_SERVICE_DISABLED - client is not permitted to
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * - request service
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * ISCSI_SERVICE_TRANSITION - client must wait for
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * - one of above two statuses
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * The hba_service_client_count tracks the number of
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * current clients, it increases with new clients and decreases
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * with leaving clients. It stops to increase once the
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * ISCSI_SERVICE_TRANSITION is set, and causes later clients be
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * blocked there.
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * The status of the service can only be changed when the number
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * of current clients reaches zero.
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * Clients include:
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * iscsi_ioctl
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * iscsi_tran_bus_config
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * iscsi_tran_bus_unconfig
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * isns_scn_callback
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China /* Default HBA tunable settings */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China iscsi_tunable_params_t hba_tunable_params;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * +--------------------------------------------------------------------+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * | iSCSI prototypes |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * +--------------------------------------------------------------------+
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap/* IDM client callback entry points */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *iscsi_get_next_text(char *data, int data_length, char *curr_text);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_ic_thread(iscsi_thread_t *thread, void *arg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_tx_thread(iscsi_thread_t *thread, void *arg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_wd_thread(iscsi_thread_t *thread, void *arg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_tx_cmd(iscsi_sess_t *isp, iscsi_cmd_t *icmdp);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapvoid iscsi_task_cleanup(int opcode, iscsi_cmd_t *icmdp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_handle_reset(iscsi_sess_t *isp, int level,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_handle_logout(iscsi_conn_t *icp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_handle_passthru(iscsi_sess_t *isp, uint16_t lun,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_handle_text(iscsi_conn_t *icp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *buf, uint32_t buf_len, uint32_t data_len, uint32_t *rx_data_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_iodone(iscsi_sess_t *isp, iscsi_cmd_t *icmdp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t iscsi_crc32c(void *address, unsigned long length);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t iscsi_crc32c_continued(void *address, unsigned long length,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_enqueue_pending_cmd(iscsi_sess_t *isp, iscsi_cmd_t *icmdp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_dequeue_pending_cmd(iscsi_sess_t *isp, iscsi_cmd_t *icmdp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_enqueue_active_cmd(iscsi_conn_t *icp, iscsi_cmd_t *icmdp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_dequeue_active_cmd(iscsi_conn_t *icp, iscsi_cmd_t *icmdp);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapvoid iscsi_enqueue_idm_aborting_cmd(iscsi_conn_t *icp, iscsi_cmd_t *icmdp);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapvoid iscsi_dequeue_idm_aborting_cmd(iscsi_conn_t *icp, iscsi_cmd_t *icmdp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_enqueue_completed_cmd(iscsi_sess_t *isp, iscsi_cmd_t *icmdp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_dequeue_cmd(iscsi_cmd_t **, iscsi_cmd_t **, iscsi_cmd_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_move_queue(iscsi_queue_t *src_queue, iscsi_queue_t *dst_queue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_enqueue_cmd_head(iscsi_cmd_t **, iscsi_cmd_t **,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapvoid iscsi_login_update_state(iscsi_conn_t *icp,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapvoid iscsi_login_update_state_locked(iscsi_conn_t *icp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t iscsi_hba_kstat_init(struct iscsi_hba *ihp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t iscsi_hba_kstat_term(struct iscsi_hba *ihp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t iscsi_sess_kstat_init(struct iscsi_sess *isp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t iscsi_sess_kstat_term(struct iscsi_sess *isp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t iscsi_conn_kstat_init(struct iscsi_conn *icp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_conn_kstat_term(struct iscsi_conn *icp);
bbe725837bc5e084e6762c7984672bc05d76baf1Jack Mengiscsi_status_t iscsi_net_interface(boolean_t reset);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSIDiscoveryMethod_t method, struct sockaddr *addr_dsc,
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing Chinavoid iscsi_sess_online(void *arg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint iscsi_sess_get(uint32_t oid, iscsi_hba_t *ihp, iscsi_sess_t **ispp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_sess_destroy(iscsi_sess_t *isp);
904e51f67bfac9f3ec88d9254757474c448808ebJack Mengvoid iscsi_sess_state_machine(iscsi_sess_t *isp, iscsi_sess_event_t event,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *iscsi_sess_state_str(iscsi_sess_state_t state);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapiscsi_status_t iscsi_sess_reserve_scsi_itt(iscsi_cmd_t *icmdp);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapvoid iscsi_sess_release_scsi_itt(iscsi_cmd_t *icmdp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_sess_reserve_itt(iscsi_sess_t *isp, iscsi_cmd_t *icmdp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_sess_release_itt(iscsi_sess_t *isp, iscsi_cmd_t *icmdp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint iscsi_sess_get_by_target(uint32_t target_oid, iscsi_hba_t *ihp,
904e51f67bfac9f3ec88d9254757474c448808ebJack Mengiscsi_enum_result_t iscsi_sess_enum_request(iscsi_sess_t *isp,
904e51f67bfac9f3ec88d9254757474c448808ebJack Mengiscsi_enum_result_t iscsi_sess_enum_query(iscsi_sess_t *isp);
904e51f67bfac9f3ec88d9254757474c448808ebJack Mengvoid iscsi_sess_enter_state_zone(iscsi_sess_t *isp);
904e51f67bfac9f3ec88d9254757474c448808ebJack Mengvoid iscsi_sess_exit_state_zone(iscsi_sess_t *isp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_conn_create(struct sockaddr *addr, iscsi_sess_t *isp,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapiscsi_status_t iscsi_conn_online(iscsi_conn_t *icp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_conn_offline(iscsi_conn_t *icp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_conn_destroy(iscsi_conn_t *icp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_conn_set_login_min_max(iscsi_conn_t *icp, int min, int max);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_conn_sync_params(iscsi_conn_t *icp);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapvoid iscsi_conn_retry(iscsi_sess_t *isp, iscsi_conn_t *icp);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapvoid iscsi_conn_update_state(iscsi_conn_t *icp, iscsi_conn_state_t next_state);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapvoid iscsi_conn_update_state_locked(iscsi_conn_t *icp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_lun_create(iscsi_sess_t *isp, uint16_t lun_num,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t lun_addr_type, struct scsi_inquiry *inq, char *guid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_lun_destroy(iscsi_hba_t *ihp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_lun_offline(iscsi_hba_t *ihp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_cmd_t *iscsi_cmd_alloc(iscsi_conn_t *icp, int km_flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid * iscsi_ioctl_copyin(caddr_t arg, int mode, size_t size);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint iscsi_ioctl_copyout(void *data, size_t size, caddr_t arg, int mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_conn_list_t *iscsi_ioctl_conn_oid_list_get_copyin(caddr_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint iscsi_ioctl_conn_oid_list_get_copyout(iscsi_conn_list_t *, caddr_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t iscsi_ioctl_conn_oid_list_get(iscsi_hba_t *ihp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t iscsi_ioctl_conn_props_get(iscsi_hba_t *ihp, iscsi_conn_props_t *cp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint iscsi_ioctl_sendtgts_get(iscsi_hba_t *ihp, iscsi_sendtgts_list_t *stl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint iscsi_target_prop_mod(iscsi_hba_t *, iscsi_property_t *, int cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint iscsi_set_params(iscsi_param_set_t *, iscsi_hba_t *, boolean_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint iscsi_get_persisted_param(uchar_t *, iscsi_param_get_t *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_set_default_login_params(iscsi_login_params_t *params);
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing Chinaint iscsi_ioctl_set_tunable_param(iscsi_hba_t *ihp,
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China iscsi_tunable_object_t *tpss);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ioctls prototypes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsid_props(iSCSIDiscoveryProperties_t *props);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t iscsid_enable_discovery(iscsi_hba_t *ihp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t iscsid_disable_discovery(iscsi_hba_t *ihp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsid_poke_discovery(iscsi_hba_t *ihp, iSCSIDiscoveryMethod_t method);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsid_config_all(iscsi_hba_t *ihp, boolean_t protect);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsid_unconfig_one(iscsi_hba_t *ihp, char *name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t iscsid_del(iscsi_hba_t *ihp, char *target_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSIDiscoveryMethod_t method, struct sockaddr *addr_dsc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t iscsid_login_tgt(iscsi_hba_t *ihp, char *target_name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSIDiscoveryMethod_t method, struct sockaddr *addr_dsc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsid_addr_to_sockaddr(int src_insize, void *src_addr, int src_port,
329c9e3ded64bba19a3bbac9ee1a0124f04dc044Jack Mengvoid iscsid_set_default_initiator_node_settings(iscsi_hba_t *ihp,
c60a6da3c3825f88388f3fba451c3dd975088f07bing zhao - Sun Microsystems - Beijing Chinavoid iscsi_send_sysevent(iscsi_hba_t *ihp, char *eventcalss,
c60a6da3c3825f88388f3fba451c3dd975088f07bing zhao - Sun Microsystems - Beijing China char *subclass, nvlist_t *np);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Mengboolean_t iscsi_reconfig_boot_sess(iscsi_hba_t *ihp);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Mengboolean_t iscsi_chk_bootlun_mpxio(iscsi_hba_t *ihp);
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Mengboolean_t iscsi_client_request_service(iscsi_hba_t *ihp);
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Mengvoid iscsi_client_release_service(iscsi_hba_t *ihp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void bcopy(const void *s1, void *s2, size_t n);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _ISCSI_H */