fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
59927d313a821b7f3822314ed16fc0a44c128431Yuri Pankov
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef _ISCSI_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _ISCSI_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Block comment which describes the contents of this file.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern "C" {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/scsi/scsi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/ddi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/sunddi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/socket.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/kstat.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/sunddi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/sunmdi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/mdi_impldefs.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/time.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nvpair.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/sdt.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
1a1a84a324206b6b1f5f704ab166c4ebf78aed76Peter Dunlap#include <sys/iscsi_protocol.h>
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#include <sys/scsi/adapters/iscsi_if.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <iscsiAuthClient.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <iscsi_stats.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <iscsi_thread.h>
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#include <sys/idm/idm.h>
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#include <sys/idm/idm_conn_sm.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <nvfile.h>
59927d313a821b7f3822314ed16fc0a44c128431Yuri Pankov#include <inet/ip.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef MIN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MIN(a, b) ((a) < (b) ? (a) : (b))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef TRUE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define TRUE 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef FALSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FALSE 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define LOGIN_PDU_BUFFER_SIZE (16 * 1024) /* move somewhere else */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapextern boolean_t iscsi_conn_logging;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapextern boolean_t iscsi_io_logging;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapextern boolean_t iscsi_login_logging;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapextern boolean_t iscsi_logging;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapextern boolean_t iscsi_sess_logging;
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_LOG if (iscsi_logging) cmn_err
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#define ISCSI_SESS_LOG if (iscsi_sess_logging) cmn_err
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Name Format of the different Task Queues
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SESS_IOTH_NAME_FORMAT "io_thrd_%d.%d"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SESS_WD_NAME_FORMAT "wd_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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
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 * to check.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_MAX_IOVEC 5
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_DEFAULT_MAX_STORM_DELAY 32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SOCKET_SNDBUF_SIZE (256 * 1024)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SOCKET_RCVBUF_SIZE (256 * 1024)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_TCP_NODELAY_DEFAULT 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_TCP_CNOTIFY_THRESHOLD_DEFAULT 2000
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_TCP_CABORT_THRESHOLD_DEFAULT 10000
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_TCP_ABORT_THRESHOLD_DEFAULT (30 * 1000) /* milliseconds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISNS_TCP_ABORT_THRESHOLD_DEFAULT (3 * 1000) /* milliseconds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Convenient short hand defines
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define TARGET_PROP "target"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define LUN_PROP "lun"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define MDI_GUID "wwn"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NDI_GUID "client-guid"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SIG_CMD 0x11111111
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SIG_LUN 0x22222222
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SIG_CONN 0x33333333
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SIG_SESS 0x44444444
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SIG_HBA 0x55555555
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SENDTARGETS_DISCOVERY "SENDTARGETS_DISCOVERY"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_LUN_MASK_MSB 0x00003f00
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_LUN_MASK_LSB 0x000000ff
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 lun[1] = (report_lun_data & ISCSI_LUN_MASK_LSB);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_INITIAL_LOGIN_STAGE -1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum iscsi_status {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Success */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_SUCCESS = 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Driver / Kernel / Code error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_INTERNAL_ERROR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ITT table is already full, unable to reserve slot */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_ITT_TABLE_FULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Login on connection failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_LOGIN_FAILED,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No connections are in the LOGGED_IN state */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_NO_CONN_LOGGED_IN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* TCP Transfer Error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_TCP_TX_ERROR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* TCP Receive Error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_TCP_RX_ERROR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI packet RCV timeout */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_RX_TIMEOUT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI Header Digest CRC error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_HEADER_DIGEST_ERROR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI Data Digest CRC error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_DATA_DIGEST_ERROR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* kmem_alloc failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_ALLOC_FAILURE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cmd (tran_abort/reset) failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_CMD_FAILED,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI protocol error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_PROTOCOL_ERROR,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI protocol version mismatch */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_VERSION_MISMATCH,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI login negotiation failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_NEGO_FAIL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI login authentication failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_AUTHENTICATION_FAILED,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI login redirection failed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_REDIRECTION_FAILED,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iSCSI uscsi status failure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_USCSI_FAILED,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* data received would have overflowed given buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_DATA_OVERFLOW,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* session/connection needs to shutdown */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_STATUS_SHUTDOWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* logical unit in use */
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap ISCSI_STATUS_BUSY,
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} iscsi_status_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SUCCESS(status) (status == ISCSI_STATUS_SUCCESS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* SNA32 check value used on increment of CmdSn values */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SNA32_CHECK 2147483648UL /* 2**31 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_CMD_TABLE_SIZE 1024
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Used on connections thread create of receiver thread */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern pri_t minclsyspri;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern ksema_t iscsid_config_semaphore;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern kmutex_t iscsi_oid_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t iscsi_oid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void *iscsi_state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_DEFAULT_NOP_DELAY 5 /* seconds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int iscsi_nop_delay;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
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 * path.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_DEFAULT_RX_WINDOW 20 /* seconds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int iscsi_rx_window;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_DEFAULT_RX_MAX_WINDOW 180 /* seconds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int iscsi_rx_max_window;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng/*
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 */
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng#define ISCSI_BOOT_DEFAULT_MAX_DELAY 180 /* seconds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * +--------------------------------------------------------------------+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * | iSCSI Driver Structures |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * +--------------------------------------------------------------------+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Auth Information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct iscsi_auth {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IscsiAuthStringBlock auth_recv_string_block;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IscsiAuthStringBlock auth_send_string_block;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IscsiAuthLargeBinary auth_recv_binary_block;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IscsiAuthLargeBinary auth_send_binary_block;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IscsiAuthClient auth_client_block;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int num_auth_buffers;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IscsiAuthBufferDesc auth_buffers[5];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int bidirectional_auth;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initiator's authentication information. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char username[iscsiAuthStringMaxLength];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t password[iscsiAuthStringMaxLength];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int password_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Target's authentication information. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char username_in[iscsiAuthStringMaxLength];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t password_in[iscsiAuthStringMaxLength];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int password_length_in;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_auth_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Task
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct iscsi_task {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *t_arg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t t_blocking;
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng uint32_t t_event_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_task_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * These are all the iscsi_cmd types that we use to track our
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * commands between queues and actions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum iscsi_cmd_type {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_CMD_TYPE_SCSI = 1, /* scsi cmd */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_CMD_TYPE_NOP, /* nop / ping */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_CMD_TYPE_ABORT, /* abort */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_CMD_TYPE_RESET, /* reset */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_CMD_TYPE_LOGOUT, /* logout */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_CMD_TYPE_LOGIN, /* login */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_CMD_TYPE_TEXT /* text */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_cmd_type_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi_cmd_state - (reference iscsi_cmd.c for state diagram)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum iscsi_cmd_state {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap ISCSI_CMD_STATE_FREE = 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_CMD_STATE_PENDING,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_CMD_STATE_ACTIVE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 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_cmd_state_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#ifdef ISCSI_CMD_SM_STRINGS
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"
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap};
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#endif
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi command events
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum iscsi_cmd_event {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap ISCSI_CMD_EVENT_E1 = 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_CMD_EVENT_E2,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_CMD_EVENT_E3,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_CMD_EVENT_E4,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_CMD_EVENT_E6,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 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_cmd_event_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#ifdef ISCSI_CMD_SM_STRINGS
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"
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap};
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#endif
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi text command stages - these stages are used by iSCSI text
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * processing to manage long resonses.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum iscsi_cmd_text_stage {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap ISCSI_CMD_TEXT_INITIAL_REQ = 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_CMD_TEXT_CONTINUATION,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_CMD_TEXT_FINAL_RSP
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_cmd_text_stage_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
d233de7e52b23edf30b2270f51e28cda6e08a98cJack Meng/*
d233de7e52b23edf30b2270f51e28cda6e08a98cJack Meng * iscsi cmd misc flags - bitwise applicable
d233de7e52b23edf30b2270f51e28cda6e08a98cJack Meng */
d233de7e52b23edf30b2270f51e28cda6e08a98cJack Meng#define ISCSI_CMD_MISCFLAG_INTERNAL 0x1
d233de7e52b23edf30b2270f51e28cda6e08a98cJack Meng#define ISCSI_CMD_MISCFLAG_FREE 0x2
d233de7e52b23edf30b2270f51e28cda6e08a98cJack Meng#define ISCSI_CMD_MISCFLAG_STUCK 0x4
b424305435881ac456a9343be2898f1f86440f31Sheng-Liang Eric Zhang#define ISCSI_CMD_MISCFLAG_XARQ 0x8
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
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China/*
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China * 1/2 of a 32 bit number, used for checking CmdSN
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China * wrapped.
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China */
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China#define ISCSI_CMD_SN_WRAP 0x80000000
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China#define ISCSI_CMD_PKT_STAT_INIT 0
d233de7e52b23edf30b2270f51e28cda6e08a98cJack Meng
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI cmd/pkt Structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct iscsi_cmd {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t cmd_sig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_cmd *cmd_prev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_cmd *cmd_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_conn *cmd_conn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_cmd_type_t cmd_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_cmd_state_t cmd_state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_cmd_state_t cmd_prev_state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t cmd_lbolt_pending;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t cmd_lbolt_active;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t cmd_lbolt_aborting;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap clock_t cmd_lbolt_idm_aborting;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t cmd_lbolt_timeout;
d233de7e52b23edf30b2270f51e28cda6e08a98cJack Meng uint8_t cmd_misc_flags;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap idm_task_t *cmd_itp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte union {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISCSI_CMD_TYPE_SCSI */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap idm_buf_t *ibp_ibuf;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap idm_buf_t *ibp_obuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct scsi_pkt *pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct buf *bp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cmdlen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int statuslen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t data_transferred;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t lun;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_cmd *abort_icmdp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pointer to the r2t associated with this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * command (if any)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_cmd *r2t_icmdp;
e790cde880fa38b13f6b938bc83aab8f9eacab06bing zhao - Sun Microsystems - Beijing China /*
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 */
e790cde880fa38b13f6b938bc83aab8f9eacab06bing zhao - Sun Microsystems - Beijing China boolean_t r2t_more;
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China /*
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China * It is used to record pkt_statistics temporarily.
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China */
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China uint_t pkt_stat;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } scsi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISCSI_CMD_TYPE_ABORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pointer to original iscsi_cmd, for abort */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_cmd *icmdp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } abort;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISCSI_CMD_TYPE_RESET */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int level;
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China uint8_t response;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } reset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISCSI_CMD_TYPE_NOP */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rsvd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } nop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISCSI_CMD_TYPE_R2T */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_cmd *icmdp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } r2t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISCSI_CMD_TYPE_LOGIN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rvsd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } login;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISCSI_CMD_TYPE_LOGOUT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rsvd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } logout;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ISCSI_CMD_TYPE_TEXT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int buf_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t offset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t data_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t total_rx_len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t ttt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t lun[8];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_cmd_text_stage_t stage;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } text;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } cmd_un;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_lun *cmd_lun; /* associated lun */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t cmd_itt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t cmd_ttt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t cmd_crc_error_seen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Used to block and wake up caller until action is completed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is for ABORT, RESET, and PASSTHRU cmds.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cmd_result;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cmd_completed;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t cmd_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t cmd_completion;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap idm_pdu_t cmd_pdu;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap sm_audit_buf_t cmd_state_audit;
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China uint32_t cmd_sn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_cmd_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI LUN Structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct iscsi_lun {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t lun_sig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int lun_state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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 dev_info_t *lun_dip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdi_pathinfo_t *lun_pip;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t lun_num; /* LUN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t lun_addr_type; /* LUN addressing type */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t lun_oid; /* OID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *lun_guid; /* GUID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int lun_guid_size; /* GUID allocation size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *lun_addr; /* sess,lun */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte time_t lun_time_online;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t lun_cap; /* bitmap of scsi caps */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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
c60a6da3c3825f88388f3fba451c3dd975088f07bing zhao - Sun Microsystems - Beijing China uchar_t lun_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_lun_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China#define ISCSI_LUN_CAP_RESET 0x01
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China#define ISCSI_SCSI_RESET_SENSE_CODE 0x29
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng#define ISCSI_SCSI_LUNCHANGED_CODE 0x3f
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng#define ISCSI_SCSI_LUNCHANGED_ASCQ 0x0e
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct iscsi_queue {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_cmd_t *head;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_cmd_t *tail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_queue_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_CONN_DEFAULT_LOGIN_MIN 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_CONN_DEFAULT_LOGIN_REDIRECT 10
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef union iscsi_sockaddr {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct sockaddr sin;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct sockaddr_in sin4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct sockaddr_in6 sin6;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_sockaddr_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SIZEOF_SOCKADDR(so) ((so)->sa_family == AF_INET ? \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (struct sockaddr_in) : sizeof (struct sockaddr_in6))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlaptypedef enum {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap LOGIN_START,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap LOGIN_READY,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap LOGIN_TX,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap LOGIN_RX,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap LOGIN_ERROR,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap LOGIN_DONE,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap LOGIN_FFP,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap LOGIN_MAX
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap} iscsi_login_state_t;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#ifdef ISCSI_LOGIN_STATE_NAMES
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapstatic const char *iscsi_login_state_names[LOGIN_MAX+1] = {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "LOGIN_START",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "LOGIN_READY",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "LOGIN_TX",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "LOGIN_RX",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "LOGIN_ERROR",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "LOGIN_DONE",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "LOGIN_FFP",
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap "LOGIN_MAX"
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap};
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#endif
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap/*
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * iscsi_conn_state
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap */
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlaptypedef enum iscsi_conn_state {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap ISCSI_CONN_STATE_UNDEFINED = 0,
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
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap} iscsi_conn_state_t;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#ifdef ISCSI_ICS_NAMES
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"
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap};
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#endif
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#define ISCSI_CONN_STATE_FULL_FEATURE(state) \
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap ((state == ISCSI_CONN_STATE_LOGGED_IN) || \
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap (state == ISCSI_CONN_STATE_IN_LOGOUT))
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Connection Structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct iscsi_conn {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t conn_sig;
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
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t conn_state_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kcondvar_t conn_state_change;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t conn_state_destroy;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap boolean_t conn_state_ffp;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap boolean_t conn_state_idm_connected;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap boolean_t conn_async_logout;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap ddi_taskq_t *conn_cn_taskq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap idm_conn_t *conn_ic;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap /* base connection information, may have been redirected */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_sockaddr_t conn_base_addr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* current connection information, may have been redirected */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_sockaddr_t conn_curr_addr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t conn_bound;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_sockaddr_t conn_bound_addr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t conn_cid; /* CID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t conn_oid; /* OID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int conn_current_stage; /* iSCSI login stage */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int conn_next_stage; /* iSCSI login stage */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int conn_partial_response;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_queue_t conn_queue_active;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap iscsi_queue_t conn_queue_idm_aborting;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* lbolt from the last receive, used for nop processing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t conn_rx_lbolt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t conn_nop_lbolt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_thread_t *conn_tx_thread;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 * recover.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t conn_expstatsn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t conn_laststatsn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* active login parameters */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_login_params_t conn_params;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Statistics */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_t *ks;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_conn_stats_t ks_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } stats;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap /*
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * These fields are used to coordinate the asynchronous IDM
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * PDU operations with the synchronous login code.
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap */
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap kmutex_t conn_login_mutex;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap kcondvar_t conn_login_cv;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap iscsi_login_state_t conn_login_state;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap iscsi_status_t conn_login_status;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap iscsi_hdr_t conn_login_resp_hdr;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap char *conn_login_data;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap int conn_login_datalen;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap int conn_login_max_data_length;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t conn_login_min;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t conn_login_max;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap sm_audit_buf_t conn_state_audit;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China
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;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_conn_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * iscsi_sess_state - (reference iscsi_sess.c for state diagram)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum iscsi_sess_state {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap ISCSI_SESS_STATE_FREE = 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_SESS_STATE_LOGGED_IN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_SESS_STATE_FAILED,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_SESS_STATE_IN_FLUSH,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap ISCSI_SESS_STATE_FLUSHED,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap ISCSI_SESS_STATE_MAX
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_sess_state_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#ifdef ISCSI_SESS_SM_STRINGS
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 Dunlap};
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#endif
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SESS_STATE_FULL_FEATURE(state) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((state == ISCSI_SESS_STATE_LOGGED_IN) || \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (state == ISCSI_SESS_STATE_IN_FLUSH))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum iscsi_sess_event {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap ISCSI_SESS_EVENT_N1 = 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_SESS_EVENT_N3,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_SESS_EVENT_N5,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_SESS_EVENT_N6,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap ISCSI_SESS_EVENT_N7,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap ISCSI_SESS_EVENT_MAX
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_sess_event_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#ifdef ISCSI_SESS_SM_STRINGS
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"
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap};
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap#endif
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum iscsi_sess_type {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap ISCSI_SESS_TYPE_NORMAL = 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISCSI_SESS_TYPE_DISCOVERY
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_sess_type_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SESS_ABORT_TASK_MAX_THREADS 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Sun's initiator session ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SUN_ISID_0 0x40 /* ISID - EN format */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SUN_ISID_1 0x00 /* Sec B */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SUN_ISID_2 0x00 /* Sec B */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SUN_ISID_3 0x2A /* Sec C - 42 = Sun's EN */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SUN_ISID_4 0x00
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_SUN_ISID_5 0xFF
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_DEFAULT_SESS_BOUND B_FALSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_DEFAULT_SESS_NUM 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
904e51f67bfac9f3ec88d9254757474c448808ebJack Mengtypedef enum iscsi_enum_status {
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng ISCSI_SESS_ENUM_FREE = 0,
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng ISCSI_SESS_ENUM_INPROG,
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng ISCSI_SESS_ENUM_DONE
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng} iscsi_enum_status_t;
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng
904e51f67bfac9f3ec88d9254757474c448808ebJack Mengtypedef enum iscsi_enum_result {
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng ISCSI_SESS_ENUM_COMPLETE = 0,
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng ISCSI_SESS_ENUM_PARTIAL,
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng ISCSI_SESS_ENUM_IOFAIL,
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng ISCSI_SESS_ENUM_SUBMITTED,
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng ISCSI_SESS_ENUM_SUBFAIL,
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng ISCSI_SESS_ENUM_GONE,
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng ISCSI_SESS_ENUM_TUR_FAIL
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng} iscsi_enum_result_t;
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI Session(Target) Structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct iscsi_sess {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t sess_sig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_sess_state_t sess_state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_sess_state_t sess_prev_state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t sess_state_lbolt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* protects the session state and synchronizes the state machine */
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng krwlock_t sess_state_rwlock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Associated target OID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t sess_target_oid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t sess_oid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_sess *sess_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_hba *sess_hba;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* list of all luns relating to session */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_lun *sess_lun_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte krwlock_t sess_lun_list_rwlock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* list of all connections relating to session */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_conn *sess_conn_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_conn *sess_conn_list_last_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pointer to active connection in session */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_conn *sess_conn_act;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte krwlock_t sess_conn_list_rwlock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Connection ID for next connection to be added to session */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t sess_conn_next_cid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * last time any connection on this session received
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * data from the target.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t sess_rx_lbolt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t sess_failure_lbolt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sess_storm_delay;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 *
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t sess_cmdsn_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 *
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t sess_cmdsn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t sess_expcmdsn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t sess_maxcmdsn;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Next Initiator Task Tag (ITT) to use */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t sess_itt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 * mutex.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct iscsi_cmd *sess_cmd_table[ISCSI_CMD_TABLE_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sess_cmd_table_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_queue_t sess_queue_pending;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_error_t sess_last_err;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_queue_t sess_queue_completion;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* configured login parameters */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_login_params_t sess_params;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* general iSCSI protocol/session info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t sess_name[ISCSI_MAX_NAME_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sess_name_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char sess_alias[ISCSI_MAX_NAME_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sess_alias_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSIDiscoveryMethod_t sess_discovered_by;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_sockaddr_t sess_discovered_addr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t sess_isid[ISCSI_ISID_LEN]; /* Session ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t sess_tsid; /* Target ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sess_tpgt_conf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This field records the negotiated TPGT value, preserved for dtrace */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sess_tpgt_nego;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Authentication information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * DCW: Again IMA seems to take a session view at this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_auth_t sess_auth;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Statistics */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_t *ks;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_sess_stats_t ks_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_t *ks_io;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_io_t ks_io_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t ks_io_lock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } stats;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_thread_t *sess_ic_thread;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t sess_window_open;
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Meng boolean_t sess_boot;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_sess_type_t sess_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng ddi_taskq_t *sess_login_taskq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_thread_t *sess_wd_thread;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap sm_audit_buf_t sess_state_audit;
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China kmutex_t sess_reset_mutex;
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China
2b79d384d32b4ea1e278466cd9b0f3bb56daae22bing zhao - Sun Microsystems - Beijing China boolean_t sess_reset_in_progress;
bbe725837bc5e084e6762c7984672bc05d76baf1Jack Meng
bbe725837bc5e084e6762c7984672bc05d76baf1Jack Meng boolean_t sess_boot_nic_reset;
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng kmutex_t sess_enum_lock;
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng kcondvar_t sess_enum_cv;
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng iscsi_enum_status_t sess_enum_status;
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng iscsi_enum_result_t sess_enum_result;
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng uint32_t sess_enum_result_count;
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng ddi_taskq_t *sess_enum_taskq;
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng kmutex_t sess_state_wmutex;
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng kcondvar_t sess_state_wcv;
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng boolean_t sess_state_hasw;
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng /* to accelerate the state change in case of new event */
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng volatile uint32_t sess_state_event_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_sess_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9ccff55d0a73a9d1d9011f705b910fba0f6e989bing zhao - Sun Microsystems - Beijing China/*
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 China */
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;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap/*
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap * iSCSI client notify task context for deferred IDM notifications processing
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap */
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlaptypedef struct iscsi_cn_task {
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap idm_conn_t *ct_ic;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap idm_client_notify_t ct_icn;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap uintptr_t ct_data;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap} iscsi_cn_task_t;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iscsi_network
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct iscsi_network {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void* (*socket)(int domain, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int (*bind)(void *, struct sockaddr *, int, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int (*connect)(void *, struct sockaddr *, int, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int (*listen)(void *, 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 int (*shutdown)(void *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*close)(void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t (*poll)(void *, clock_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t (*sendmsg)(void *, struct msghdr *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size_t (*recvmsg)(void *, struct msghdr *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sndbuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rcvbuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int nodelay;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int conn_notify_threshold;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int conn_abort_threshold;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int abort_threshold;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } tweaks;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_network_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_NET_HEADER_DIGEST 0x00000001
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_NET_DATA_DIGEST 0x00000002
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern iscsi_network_t *iscsi_net;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ISCSI_CONFIG_STORM_DELAY_DEFAULT 5
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI HBA Structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct iscsi_hba {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t hba_sig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_info_t *hba_dip; /* dev info ptr */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_hba_tran_t *hba_tran; /* scsi tran ptr */
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap ldi_ident_t hba_li;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* lbolt of the last time we received a config request */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t hba_config_lbolt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* current number of seconds to protect against bus config storms */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int hba_config_storm_delay;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* general iSCSI protocol hba/initiator info */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t hba_name[ISCSI_MAX_NAME_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int hba_name_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t hba_alias[ISCSI_MAX_NAME_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int hba_alias_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Default SessionID for HBA */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t hba_isid[ISCSI_ISID_LEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Default HBA wide settings */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_login_params_t hba_params;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t hba_oid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * see.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmutex_t hba_discovery_events_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSIDiscoveryMethod_t hba_discovery_events;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t hba_discovery_in_progress;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t hba_mpxio_enabled; /* mpxio-enabled */
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng /* if the persistent store is loaded */
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng boolean_t hba_persistent_loaded;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Ensures only one SendTargets operation occurs at a time
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ksema_t hba_sendtgts_semaphore;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Statistics
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_t *ks;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_hba_stats_t ks_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } stats;
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng /*
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * track/control the service status and client
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng *
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 *
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 *
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * The service has three status:
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * ISCSI_SERVICE_ENABLED - client is permitted to
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * - request service
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng *
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * ISCSI_SERVICE_DISABLED - client is not permitted to
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * - request service
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng *
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * ISCSI_SERVICE_TRANSITION - client must wait for
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * - one of above two statuses
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng *
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 *
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * The status of the service can only be changed when the number
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng * of current clients reaches zero.
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng *
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
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng */
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng kmutex_t hba_service_lock;
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng kcondvar_t hba_service_cv;
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng uint32_t hba_service_status;
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Meng uint32_t hba_service_client_count;
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China /* Default HBA tunable settings */
aff4bce51ecc47df7e5a6351b7cee6bc20408c63yi zhang - Sun Microsystems - Beijing China iscsi_tunable_params_t hba_tunable_params;
49311b3511690f5b23558b0fba067bc8067c7a87Jack Meng boolean_t hba_service_status_overwrite;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} iscsi_hba_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * +--------------------------------------------------------------------+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * | iSCSI prototypes |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * +--------------------------------------------------------------------+
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap/* IDM client callback entry points */
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapidm_rx_pdu_cb_t iscsi_rx_scsi_rsp;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapidm_rx_pdu_cb_t iscsi_rx_misc_pdu;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapidm_rx_pdu_error_cb_t iscsi_rx_error_pdu;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapidm_build_hdr_cb_t iscsi_build_hdr;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapidm_task_cb_t iscsi_task_aborted;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapidm_client_notify_cb_t iscsi_client_notify;
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* iscsi_io.c */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint iscsi_sna_lte(uint32_t n1, uint32_t n2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *iscsi_get_next_text(char *data, int data_length, char *curr_text);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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 Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_tx_cmd(iscsi_sess_t *isp, iscsi_cmd_t *icmdp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapvoid iscsi_task_cleanup(int opcode, iscsi_cmd_t *icmdp);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_handle_abort(void *arg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_handle_reset(iscsi_sess_t *isp, int level,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_lun_t *ilp);
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 Forte struct uscsi_cmd *ucmdp);
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 Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_iodone(iscsi_sess_t *isp, iscsi_cmd_t *icmdp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* iscsi_crc.c */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t iscsi_crc32c(void *address, unsigned long length);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuint32_t iscsi_crc32c_continued(void *address, unsigned long length,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t crc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* iscsi_queue.c */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_init_queue(iscsi_queue_t *queue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_destroy_queue(iscsi_queue_t *queue);
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 **,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_cmd_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* iscsi_login.c */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_login_start(void *arg);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapvoid iscsi_login_update_state(iscsi_conn_t *icp,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap iscsi_login_state_t next_state);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlapvoid iscsi_login_update_state_locked(iscsi_conn_t *icp,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap iscsi_login_state_t next_state);
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* iscsi_stats.c */
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);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* iscsi_net.c */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_net_init();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_net_fini();
bbe725837bc5e084e6762c7984672bc05d76baf1Jack Mengiscsi_status_t iscsi_net_interface(boolean_t reset);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* iscsi_sess.c */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_sess_t *iscsi_sess_create(iscsi_hba_t *ihp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSIDiscoveryMethod_t method, struct sockaddr *addr_dsc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *target_name, int tpgt, uchar_t isid_lsb,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_sess_type_t type, uint32_t *oid);
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,
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng uint32_t event_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *iscsi_sess_state_str(iscsi_sess_state_t state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t iscsi_sess_set_auth(iscsi_sess_t *isp);
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 Fortevoid iscsi_sess_redrive_io(iscsi_sess_t *isp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint iscsi_sess_get_by_target(uint32_t target_oid, iscsi_hba_t *ihp,
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng iscsi_sess_t **ispp);
904e51f67bfac9f3ec88d9254757474c448808ebJack Mengiscsi_enum_result_t iscsi_sess_enum_request(iscsi_sess_t *isp,
904e51f67bfac9f3ec88d9254757474c448808ebJack Meng boolean_t wait, uint32_t event_count);
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 Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* iscsi_conn.c */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_conn_create(struct sockaddr *addr, iscsi_sess_t *isp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_conn_t **icpp);
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,
30e7468f8f41aa30ada067b2c1d5d284046514daPeter Dunlap iscsi_conn_state_t next_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* iscsi_lun.c */
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 Forte iscsi_lun_t *ilp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_lun_online(iscsi_hba_t *ihp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_lun_t *ilp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_status_t iscsi_lun_offline(iscsi_hba_t *ihp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_lun_t *ilp, boolean_t lun_free);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* iscsi_cmd.c */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_cmd_state_machine(iscsi_cmd_t *icmdp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_cmd_event_t event, void *arg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_cmd_t *iscsi_cmd_alloc(iscsi_conn_t *icp, int km_flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_cmd_free(iscsi_cmd_t *icmdp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* iscsi_ioctl.c */
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 Forte iscsi_conn_list_t *cl);
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 Forte iscsi_login_params_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsi_set_default_login_params(iscsi_login_params_t *params);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint iscsi_ioctl_get_config_sess(iscsi_hba_t *ihp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_config_sess_t *ics);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint iscsi_ioctl_set_config_sess(iscsi_hba_t *ihp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_config_sess_t *ics);
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 Forteint iscsi_get_param(iscsi_login_params_t *params,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte boolean_t valid_flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_param_get_t *ipgp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* iscsid.c */
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Mengboolean_t iscsid_init(iscsi_hba_t *ihp);
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Mengboolean_t iscsid_start(iscsi_hba_t *ihp);
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Mengboolean_t iscsid_stop(iscsi_hba_t *ihp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsid_fini();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsid_props(iSCSIDiscoveryProperties_t *props);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t iscsid_enable_discovery(iscsi_hba_t *ihp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSIDiscoveryMethod_t idm, boolean_t poke);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteboolean_t iscsid_disable_discovery(iscsi_hba_t *ihp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iSCSIDiscoveryMethod_t idm);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsid_poke_discovery(iscsi_hba_t *ihp, iSCSIDiscoveryMethod_t method);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsid_do_sendtgts(entry_t *discovery_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsid_do_isns_query_one_server(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_hba_t *ihp, entry_t *isns_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsid_do_isns_query(iscsi_hba_t *ihp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsid_config_one(iscsi_hba_t *ihp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *name, boolean_t protect);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsid_config_all(iscsi_hba_t *ihp, boolean_t protect);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsid_unconfig_one(iscsi_hba_t *ihp, char *name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid iscsid_unconfig_all(iscsi_hba_t *ihp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid isns_scn_callback(void *arg);
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,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct sockaddr *dst_addr);
329c9e3ded64bba19a3bbac9ee1a0124f04dc044Jack Mengvoid iscsid_set_default_initiator_node_settings(iscsi_hba_t *ihp,
329c9e3ded64bba19a3bbac9ee1a0124f04dc044Jack Meng boolean_t minimal);
329c9e3ded64bba19a3bbac9ee1a0124f04dc044Jack Meng
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);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Mengboolean_t iscsi_cmp_boot_ini_name(char *name);
6cefaae1e90a413ba01560575bb3998e1a3df40eJack Mengboolean_t iscsi_cmp_boot_tgt_name(char *name);
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Mengboolean_t iscsi_client_request_service(iscsi_hba_t *ihp);
4246c8e92ef9ad6ada2b992b7af02832ff071bf7Jack Mengvoid iscsi_client_release_service(iscsi_hba_t *ihp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void bcopy(const void *s1, void *s2, size_t n);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void bzero(void *s, size_t n);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _ISCSI_H */