Home | History | Annotate | Line # | Download | only in iscsi
      1  1.3       dsl /*	$NetBSD: iscsi_ioctl.h,v 1.3 2013/04/04 22:17:13 dsl Exp $	*/
      2  1.1       agc 
      3  1.1       agc /*-
      4  1.1       agc  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
      5  1.1       agc  * All rights reserved.
      6  1.1       agc  *
      7  1.1       agc  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1       agc  * by Wasabi Systems, Inc.
      9  1.1       agc  *
     10  1.1       agc  * Redistribution and use in source and binary forms, with or without
     11  1.1       agc  * modification, are permitted provided that the following conditions
     12  1.1       agc  * are met:
     13  1.1       agc  * 1. Redistributions of source code must retain the above copyright
     14  1.1       agc  *    notice, this list of conditions and the following disclaimer.
     15  1.1       agc  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1       agc  *    notice, this list of conditions and the following disclaimer in the
     17  1.1       agc  *    documentation and/or other materials provided with the distribution.
     18  1.1       agc  *
     19  1.1       agc  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.1       agc  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.1       agc  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.1       agc  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.1       agc  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.1       agc  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.1       agc  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.1       agc  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.1       agc  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.1       agc  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.1       agc  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1       agc  */
     31  1.1       agc #ifndef _ISCSI_IOCTL_H
     32  1.1       agc #define _ISCSI_IOCTL_H
     33  1.1       agc 
     34  1.1       agc #include <dev/iscsi/iscsi.h>
     35  1.3       dsl #include <sys/scsiio.h>
     36  1.1       agc 
     37  1.1       agc /* ==================  Interface Structures ======================== */
     38  1.1       agc 
     39  1.1       agc /* ===== Login, add_connection, and restore_connection ===== */
     40  1.1       agc 
     41  1.1       agc typedef struct {
     42  1.1       agc 	uint32_t status;
     43  1.1       agc 	int socket;
     44  1.1       agc 	struct {
     45  1.2  christos 		unsigned int HeaderDigest:1;
     46  1.2  christos 		unsigned int DataDigest:1;
     47  1.2  christos 		unsigned int MaxConnections:1;
     48  1.2  christos 		unsigned int DefaultTime2Wait:1;
     49  1.2  christos 		unsigned int DefaultTime2Retain:1;
     50  1.2  christos 		unsigned int MaxRecvDataSegmentLength:1;
     51  1.2  christos 		unsigned int auth_info:1;
     52  1.2  christos 		unsigned int user_name:1;
     53  1.2  christos 		unsigned int password:1;
     54  1.2  christos 		unsigned int target_password:1;
     55  1.2  christos 		unsigned int TargetName:1;
     56  1.2  christos 		unsigned int TargetAlias:1;
     57  1.2  christos 		unsigned int ErrorRecoveryLevel:1;
     58  1.1       agc 	} is_present;
     59  1.1       agc 	iscsi_auth_info_t auth_info;
     60  1.1       agc 	iscsi_login_session_type_t login_type;
     61  1.1       agc 	iscsi_digest_t HeaderDigest;
     62  1.1       agc 	iscsi_digest_t DataDigest;
     63  1.1       agc 	uint32_t session_id;
     64  1.1       agc 	uint32_t connection_id;
     65  1.1       agc 	uint32_t MaxRecvDataSegmentLength;
     66  1.1       agc 	uint16_t MaxConnections;
     67  1.1       agc 	uint16_t DefaultTime2Wait;
     68  1.1       agc 	uint16_t DefaultTime2Retain;
     69  1.1       agc 	uint16_t ErrorRecoveryLevel;
     70  1.1       agc 	void *user_name;
     71  1.1       agc 	void *password;
     72  1.1       agc 	void *target_password;
     73  1.1       agc 	void *TargetName;
     74  1.1       agc 	void *TargetAlias;
     75  1.1       agc } iscsi_login_parameters_t;
     76  1.1       agc 
     77  1.1       agc /*
     78  1.1       agc    status
     79  1.1       agc       Contains, on return, the result of the command.
     80  1.1       agc    socket
     81  1.1       agc       A handle to the open TCP connection to the target portal.
     82  1.1       agc    is_present
     83  1.1       agc       Contains a bitfield that indicates which members of the
     84  1.1       agc       iscsi_login_parameters structure contain valid data.
     85  1.1       agc    auth_info
     86  1.1       agc       Is a bitfield of parameters for authorization.
     87  1.1       agc       The members are
     88  1.1       agc          mutual_auth Indicates that authentication should be mutual, i.e.
     89  1.1       agc             the initiator should authenticate the target, and the target
     90  1.1       agc             should authenticate the initiator. If not specified, the target
     91  1.1       agc             will authenticate the initiator only.
     92  1.1       agc          is_secure   Indicates that the connection is secure.
     93  1.1       agc          auth_number Indicates the number of elements in auth_type.
     94  1.1       agc             When 0, no authentication will be used.
     95  1.1       agc    auth_type
     96  1.1       agc       Contains up to ISCSI_AUTH_OPTIONS enumerator values of type
     97  1.1       agc       iscsi_auth_types that indicates the authentication method that should
     98  1.1       agc       be used to establish a login connection (none, CHAP, KRB5, etc.), in
     99  1.1       agc       order of priority.  The first element is the most preferred method, the
    100  1.1       agc       last element the least preferred.
    101  1.1       agc    login_type
    102  1.1       agc       Contains an enumerator value of type login_session_type that indicates
    103  1.1       agc       the type of logon session (discovery, informational, or full featured).
    104  1.1       agc    HeaderDigest
    105  1.1       agc       Indicates which digest (if any) to use for the PDU header.
    106  1.1       agc    DataDigest
    107  1.1       agc       Indicates which digest (if any) to use for the PDU data.
    108  1.1       agc    session_id
    109  1.1       agc       Login: OUT: Receives an integer that identifies the session.
    110  1.1       agc       Add_connection, Restore_connection: IN: Session ID.
    111  1.1       agc    connection_id
    112  1.1       agc       Login, Add_connection: OUT: Receives an integer that identifies the
    113  1.1       agc       connection.
    114  1.1       agc       Restore_connection: IN: Connection ID.
    115  1.1       agc    MaxRecvDataSegmentLength
    116  1.1       agc       Allows limiting or extending the maximum receive data segment length.
    117  1.1       agc       Must contain a value between 512 and 2**24-1 if specified.
    118  1.1       agc    MaxConnections
    119  1.1       agc       Contains a value between 1 and 65535 that specifies the maximum number
    120  1.1       agc       of connections to target devices that can be associated with a single
    121  1.1       agc       logon session. A value of 0 indicates that there no limit to the
    122  1.1       agc       number of connections.
    123  1.1       agc    DefaultTime2Wait
    124  1.1       agc       Specifies the minimum time to wait, in seconds, before attempting to
    125  1.1       agc       reconnect or reassign a connection that has been dropped.
    126  1.1       agc 	  The default is 2.
    127  1.1       agc    DefaultTime2Retain
    128  1.1       agc       Specifies the maximum time, in seconds, allowed to reassign a
    129  1.1       agc       connection after the initial wait indicated in DefaultTime2Retain has
    130  1.1       agc       elapsed. The default is 20.
    131  1.1       agc    ErrorRecoveryLevel
    132  1.1       agc       Specifies the desired error recovery level for the session.
    133  1.1       agc 	  The default and maximum is 2.
    134  1.1       agc    user_name
    135  1.1       agc       Sets the user (or CHAP) name to use during login authentication of the
    136  1.1       agc       initiator (zero terminated UTF-8 string). Default is initiator name.
    137  1.1       agc    password
    138  1.1       agc       Contains the password to use during login authentication of the
    139  1.1       agc       initiator (zero terminated UTF-8 string). Required if authentication
    140  1.1       agc       is requested.
    141  1.1       agc    target_password
    142  1.1       agc       Contains the password to use during login authentication of the target
    143  1.1       agc       (zero terminated UTF-8 string). Required if mutual authentication is
    144  1.1       agc       requested.
    145  1.1       agc    TargetName
    146  1.1       agc       Indicates the name of the target with which to establish the logon
    147  1.1       agc       session (zero terminated UTF-8 string).
    148  1.1       agc    TargetAlias
    149  1.1       agc       Receives the target alias as a zero terminated UTF-8 string. When
    150  1.1       agc       present, the buffer must be of size ISCSI_STRING_LENGTH.
    151  1.1       agc */
    152  1.1       agc 
    153  1.1       agc 
    154  1.1       agc /* ===== Logout ===== */
    155  1.1       agc 
    156  1.1       agc typedef struct {
    157  1.1       agc 	uint32_t status;
    158  1.1       agc 	uint32_t session_id;
    159  1.1       agc } iscsi_logout_parameters_t;
    160  1.1       agc 
    161  1.1       agc /*
    162  1.1       agc    status
    163  1.1       agc       Contains, on return, the result of the command.
    164  1.1       agc    session_id
    165  1.1       agc       Contains an integer that identifies the session.
    166  1.1       agc */
    167  1.1       agc 
    168  1.1       agc /* ===== remove_connection ===== */
    169  1.1       agc 
    170  1.1       agc typedef struct {
    171  1.1       agc 	uint32_t status;
    172  1.1       agc 	uint32_t session_id;
    173  1.1       agc 	uint32_t connection_id;
    174  1.1       agc } iscsi_remove_parameters_t;
    175  1.1       agc 
    176  1.1       agc /*
    177  1.1       agc    status
    178  1.1       agc       Contains, on return, the result of the command.
    179  1.1       agc    session_id
    180  1.1       agc       Contains an integer that identifies the session.
    181  1.1       agc    connection_id
    182  1.1       agc       Contains an integer that identifies the connection.
    183  1.1       agc */
    184  1.1       agc 
    185  1.1       agc /* ===== connection status ===== */
    186  1.1       agc 
    187  1.1       agc typedef struct {
    188  1.1       agc 	uint32_t status;
    189  1.1       agc 	uint32_t session_id;
    190  1.1       agc 	uint32_t connection_id;
    191  1.1       agc } iscsi_conn_status_parameters_t;
    192  1.1       agc 
    193  1.1       agc /*
    194  1.1       agc    status
    195  1.1       agc       Contains, on return, the result of the command.
    196  1.1       agc    session_id
    197  1.1       agc       Contains an integer that identifies the session.
    198  1.1       agc    connection_id
    199  1.1       agc       Contains an integer that identifies the connection.
    200  1.1       agc */
    201  1.1       agc 
    202  1.1       agc /* ===== io_command ===== */
    203  1.1       agc 
    204  1.1       agc typedef struct {
    205  1.1       agc 	uint32_t status;
    206  1.1       agc 	uint32_t session_id;
    207  1.1       agc 	uint32_t connection_id;
    208  1.1       agc 	struct {
    209  1.2  christos 		unsigned int immediate:1;
    210  1.1       agc 	} options;
    211  1.1       agc 	uint64_t lun;
    212  1.1       agc 	scsireq_t req;
    213  1.1       agc } iscsi_iocommand_parameters_t;
    214  1.1       agc 
    215  1.1       agc /*
    216  1.1       agc    status
    217  1.1       agc       Contains, on return, the result of the command (an ISCSI_STATUS code).
    218  1.1       agc    lun
    219  1.1       agc       Indicates which of the target's logical units should provide the data.
    220  1.1       agc    session_id
    221  1.1       agc       Contains an integer that identifies the session.
    222  1.1       agc    connection_id
    223  1.1       agc       Contains an integer that identifies the connection.
    224  1.1       agc       This parameter is optional and should only be used for test purposes.
    225  1.1       agc    options
    226  1.1       agc       A bitfield indicating options for the command.
    227  1.1       agc       The members are
    228  1.1       agc          immediate   Indicates that the command should be sent
    229  1.1       agc                      immediately, ahead of any queued requests.
    230  1.1       agc 
    231  1.1       agc    req
    232  1.1       agc       Contains the parameters for the request as defined in sys/scsiio.h
    233  1.1       agc       typedef struct scsireq {
    234  1.1       agc          u_long   flags;
    235  1.1       agc          u_long   timeout;
    236  1.1       agc          uint8_t   cmd[16];
    237  1.1       agc          uint8_t   cmdlen;
    238  1.1       agc          void * databuf;
    239  1.1       agc          u_long   datalen;
    240  1.1       agc          u_long   datalen_used;
    241  1.1       agc          uint8_t   sense[SENSEBUFLEN];
    242  1.1       agc          uint8_t   senselen;
    243  1.1       agc          uint8_t   senselen_used;
    244  1.1       agc          uint8_t   status;
    245  1.1       agc          uint8_t   retsts;
    246  1.1       agc          int      error;
    247  1.1       agc       } scsireq_t;
    248  1.1       agc 
    249  1.1       agc       flags
    250  1.1       agc          Indicates request status and type.
    251  1.1       agc       timeout
    252  1.1       agc          Indicates a timeout value (reserved).
    253  1.1       agc       cmd
    254  1.1       agc          SCSI command buffer.
    255  1.1       agc       cmdlen
    256  1.1       agc          Length of SCSI command in cmd.
    257  1.1       agc       databuf
    258  1.1       agc          Pointer to user-space buffer that holds the data
    259  1.1       agc          read or written by the SCSI command.
    260  1.1       agc       datalen
    261  1.1       agc          Indicates the size in bytes of the buffer at databuf.
    262  1.1       agc       datalen_used
    263  1.1       agc          Returns the number of bytes actually read or written.
    264  1.1       agc       sense
    265  1.1       agc          Sense data buffer.
    266  1.1       agc       senselen
    267  1.1       agc          Indicates the requested size of sense data. Must not exceed
    268  1.1       agc          SENSEBUFLEN (48).
    269  1.1       agc       senselen_used
    270  1.1       agc          Contains, on return, the number of bytes written to sense.
    271  1.1       agc       status
    272  1.1       agc          Contains, on return, the original SCSI status (reserved).
    273  1.1       agc       retsts
    274  1.1       agc          Contains, on return, the status of the command as defined in scsiio.h.
    275  1.1       agc       error
    276  1.1       agc          Contains, on return, the original SCSI error bits (reserved).
    277  1.1       agc */
    278  1.1       agc 
    279  1.1       agc 
    280  1.1       agc /* ===== send_targets ===== */
    281  1.1       agc 
    282  1.1       agc typedef struct {
    283  1.1       agc 	uint32_t status;
    284  1.1       agc 	uint32_t session_id;
    285  1.1       agc 	void *response_buffer;
    286  1.1       agc 	uint32_t response_size;
    287  1.1       agc 	uint32_t response_used;
    288  1.1       agc 	uint32_t response_total;
    289  1.1       agc 	uint8_t key[ISCSI_STRING_LENGTH];
    290  1.1       agc } iscsi_send_targets_parameters_t;
    291  1.1       agc 
    292  1.1       agc /*
    293  1.1       agc    status
    294  1.1       agc       Contains, on return, the result of the command.
    295  1.1       agc    session_id
    296  1.1       agc       Contains an integer that identifies the session.
    297  1.1       agc    response_buffer
    298  1.1       agc       User mode address of buffer to hold the response data retrieved by
    299  1.1       agc       the iSCSI send targets command.
    300  1.1       agc    response_size
    301  1.1       agc       Contains, on input, the size in bytes of the buffer at
    302  1.1       agc       response_buffer. If this is 0, the command will execute the
    303  1.1       agc       SendTargets request, and return (in response_total) the number of
    304  1.1       agc       bytes required.
    305  1.1       agc    response_used
    306  1.1       agc       Contains, on return, the number of bytes actually retrieved to
    307  1.1       agc       response_buffer.
    308  1.1       agc    response_total
    309  1.1       agc       Contains, on return, the total number of bytes required to hold the
    310  1.1       agc       complete list of targets. This may be larger than response_size.
    311  1.1       agc    key
    312  1.1       agc       Specifies the SendTargets key value ("All", <target name>, or empty).
    313  1.1       agc */
    314  1.1       agc 
    315  1.1       agc /* ===== set_node_name ===== */
    316  1.1       agc 
    317  1.1       agc typedef struct {
    318  1.1       agc 	uint32_t status;
    319  1.1       agc 	uint8_t InitiatorName[ISCSI_STRING_LENGTH];
    320  1.1       agc 	uint8_t InitiatorAlias[ISCSI_STRING_LENGTH];
    321  1.1       agc 	uint8_t ISID[6];
    322  1.1       agc } iscsi_set_node_name_parameters_t;
    323  1.1       agc 
    324  1.1       agc /*
    325  1.1       agc    status
    326  1.1       agc       Contains, on return, the result of the command.
    327  1.1       agc    InitiatorName
    328  1.1       agc       Specifies the InitiatorName used during login. Required.
    329  1.1       agc    InitiatorAlias
    330  1.1       agc       Specifies the InitiatorAlias for use during login. May be empty.
    331  1.1       agc    ISID
    332  1.1       agc       Specifies the ISID (a 6 byte binary value) for use during login.
    333  1.1       agc       May be zero (all bytes) for the initiator to use a default value.
    334  1.1       agc */
    335  1.1       agc 
    336  1.1       agc /* ===== register_event and deregister_event ===== */
    337  1.1       agc 
    338  1.1       agc typedef struct {
    339  1.1       agc 	uint32_t status;
    340  1.1       agc 	uint32_t event_id;
    341  1.1       agc } iscsi_register_event_parameters_t;
    342  1.1       agc 
    343  1.1       agc /*
    344  1.1       agc    status
    345  1.1       agc       Contains, on return, the result of the command.
    346  1.1       agc    event_id
    347  1.1       agc       Returns driver-assigned event ID to be used in
    348  1.1       agc       subsequent calls to wait_event and deregister_event.
    349  1.1       agc */
    350  1.1       agc 
    351  1.1       agc /* ===== wait_event ===== */
    352  1.1       agc 
    353  1.1       agc typedef enum {
    354  1.1       agc 	ISCSI_SESSION_TERMINATED = 1,
    355  1.1       agc 	ISCSI_CONNECTION_TERMINATED,
    356  1.1       agc 	ISCSI_RECOVER_CONNECTION,
    357  1.1       agc 	ISCSI_DRIVER_TERMINATING
    358  1.1       agc } iscsi_event_t;
    359  1.1       agc 
    360  1.1       agc /*
    361  1.1       agc    Driver Events
    362  1.1       agc 
    363  1.1       agc    ISCSI_SESSION_TERMINATED
    364  1.1       agc       The specified session (including all of its associated connections)
    365  1.1       agc       has been terminated.
    366  1.1       agc    ISCSI_CONNECTION_TERMINATED
    367  1.1       agc       The specified connection has been terminated.
    368  1.1       agc    ISCSI_RECOVER_CONNECTION
    369  1.1       agc       The application should attempt to recover the given connection.
    370  1.1       agc    ISCSI_DRIVER_TERMINATING
    371  1.1       agc       The driver is unloading.
    372  1.1       agc       The application MUST call ISCSI_DEREGISTER_EVENT as soon as possible
    373  1.1       agc       after receiving this event. After performing the deregister IOCTL,
    374  1.1       agc       the application must no longer attempt to access the driver.
    375  1.1       agc */
    376  1.1       agc 
    377  1.1       agc 
    378  1.1       agc typedef struct {
    379  1.1       agc 	uint32_t status;
    380  1.1       agc 	uint32_t event_id;
    381  1.1       agc 	iscsi_event_t event_kind;
    382  1.1       agc 	uint32_t session_id;
    383  1.1       agc 	uint32_t connection_id;
    384  1.1       agc 	uint32_t reason;
    385  1.1       agc } iscsi_wait_event_parameters_t;
    386  1.1       agc 
    387  1.1       agc /*
    388  1.1       agc    status
    389  1.1       agc       Contains, on return, the result of the command.
    390  1.1       agc    event_id
    391  1.1       agc       Driver assigned event ID.
    392  1.1       agc    event_kind
    393  1.1       agc       Identifies the event.
    394  1.1       agc    session_id
    395  1.1       agc       Identifies the affected session (0 for DRIVER_TERMINATING).
    396  1.1       agc    connection_id
    397  1.1       agc       Identifies the affected connection (0 for DRIVER_TERMINATING).
    398  1.1       agc    reason
    399  1.1       agc       Identifies the termination reason (ISCSI status code).
    400  1.1       agc */
    401  1.1       agc 
    402  1.1       agc typedef struct {
    403  1.1       agc 	uint32_t status;
    404  1.1       agc 	uint16_t interface_version;
    405  1.1       agc 	uint16_t major;
    406  1.1       agc 	uint16_t minor;
    407  1.1       agc 	uint8_t version_string[ISCSI_STRING_LENGTH];
    408  1.1       agc } iscsi_get_version_parameters_t;
    409  1.1       agc 
    410  1.1       agc /*
    411  1.1       agc    status
    412  1.1       agc       Contains, on return, the result of the command.
    413  1.1       agc    interface_version
    414  1.1       agc       Updated when interface changes. Current Version is 2.
    415  1.1       agc    major
    416  1.1       agc       Major version number.
    417  1.1       agc    minor
    418  1.1       agc       Minor version number.
    419  1.1       agc    version_string
    420  1.1       agc       Displayable version string (zero terminated).
    421  1.1       agc */
    422  1.1       agc 
    423  1.1       agc /* =========================  IOCTL Codes =========================== */
    424  1.1       agc 
    425  1.1       agc #define ISCSI_GET_VERSION        _IOWR(0,  1, iscsi_get_version_parameters_t)
    426  1.1       agc #define ISCSI_LOGIN              _IOWR(0,  2, iscsi_login_parameters_t)
    427  1.1       agc #define ISCSI_LOGOUT             _IOWR(0,  3, iscsi_logout_parameters_t)
    428  1.1       agc #define ISCSI_ADD_CONNECTION     _IOWR(0,  4, iscsi_login_parameters_t)
    429  1.1       agc #define ISCSI_RESTORE_CONNECTION _IOWR(0,  5, iscsi_login_parameters_t)
    430  1.1       agc #define ISCSI_REMOVE_CONNECTION  _IOWR(0,  6, iscsi_remove_parameters_t)
    431  1.1       agc #define ISCSI_CONNECTION_STATUS  _IOWR(0,  7, iscsi_conn_status_parameters_t)
    432  1.1       agc #define ISCSI_SEND_TARGETS       _IOWR(0,  8, iscsi_send_targets_parameters_t)
    433  1.1       agc #define ISCSI_SET_NODE_NAME      _IOWR(0,  9, iscsi_set_node_name_parameters_t)
    434  1.1       agc #define ISCSI_IO_COMMAND         _IOWR(0, 10, iscsi_iocommand_parameters_t)
    435  1.1       agc #define ISCSI_REGISTER_EVENT     _IOWR(0, 11, iscsi_register_event_parameters_t)
    436  1.1       agc #define ISCSI_DEREGISTER_EVENT   _IOWR(0, 12, iscsi_register_event_parameters_t)
    437  1.1       agc #define ISCSI_WAIT_EVENT         _IOWR(0, 13, iscsi_wait_event_parameters_t)
    438  1.1       agc #define ISCSI_POLL_EVENT         _IOWR(0, 14, iscsi_wait_event_parameters_t)
    439  1.1       agc 
    440  1.1       agc #endif /* !_ISCSI_IOCTL_H */
    441