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