iscsi_ioctl.h revision 255678
1255570Strasz/*- 2255570Strasz * Copyright (c) 2012 The FreeBSD Foundation 3255570Strasz * All rights reserved. 4255570Strasz * 5255570Strasz * This software was developed by Edward Tomasz Napierala under sponsorship 6255570Strasz * from the FreeBSD Foundation. 7255570Strasz * 8255570Strasz * Redistribution and use in source and binary forms, with or without 9255570Strasz * modification, are permitted provided that the following conditions 10255570Strasz * are met: 11255570Strasz * 1. Redistributions of source code must retain the above copyright 12255570Strasz * notice, this list of conditions and the following disclaimer. 13255570Strasz * 2. Redistributions in binary form must reproduce the above copyright 14255570Strasz * notice, this list of conditions and the following disclaimer in the 15255570Strasz * documentation and/or other materials provided with the distribution. 16255570Strasz * 17255570Strasz * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18255570Strasz * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19255570Strasz * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20255570Strasz * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21255570Strasz * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22255570Strasz * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23255570Strasz * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24255570Strasz * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25255570Strasz * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26255570Strasz * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27255570Strasz * SUCH DAMAGE. 28255570Strasz * 29255570Strasz * $FreeBSD: head/sys/dev/iscsi/iscsi_ioctl.h 255678 2013-09-18 21:15:21Z trasz $ 30255570Strasz */ 31255570Strasz 32255570Strasz#ifndef ISCSI_IOCTL_H 33255570Strasz#define ISCSI_IOCTL_H 34255570Strasz 35255570Strasz#ifdef ICL_KERNEL_PROXY 36255570Strasz#include <sys/socket.h> 37255570Strasz#endif 38255570Strasz 39255570Strasz#define ISCSI_PATH "/dev/iscsi" 40255570Strasz#define ISCSI_MAX_DATA_SEGMENT_LENGTH (128 * 1024) 41255570Strasz 42255570Strasz#define ISCSI_NAME_LEN 224 /* 223 bytes, by RFC 3720, + '\0' */ 43255570Strasz#define ISCSI_ADDR_LEN 47 /* INET6_ADDRSTRLEN + '\0' */ 44255570Strasz#define ISCSI_ALIAS_LEN 256 /* XXX: Where did it come from? */ 45255570Strasz#define ISCSI_SECRET_LEN 17 /* 16 + '\0' */ 46255678Strasz#define ISCSI_REASON_LEN 64 47255570Strasz 48255570Strasz#define ISCSI_DIGEST_NONE 0 49255570Strasz#define ISCSI_DIGEST_CRC32C 1 50255570Strasz 51255570Strasz/* 52255570Strasz * Session configuration, set when adding the session. 53255570Strasz */ 54255570Straszstruct iscsi_session_conf { 55255570Strasz char isc_initiator[ISCSI_NAME_LEN]; 56255570Strasz char isc_initiator_addr[ISCSI_ADDR_LEN]; 57255570Strasz char isc_initiator_alias[ISCSI_ALIAS_LEN]; 58255570Strasz char isc_target[ISCSI_NAME_LEN]; 59255570Strasz char isc_target_addr[ISCSI_ADDR_LEN]; 60255570Strasz char isc_user[ISCSI_NAME_LEN]; 61255570Strasz char isc_secret[ISCSI_SECRET_LEN]; 62255570Strasz char isc_mutual_user[ISCSI_NAME_LEN]; 63255570Strasz char isc_mutual_secret[ISCSI_SECRET_LEN]; 64255570Strasz int isc_discovery; 65255570Strasz int isc_header_digest; 66255570Strasz int isc_data_digest; 67255570Strasz int isc_iser; 68255570Strasz int isc_spare[4]; 69255570Strasz}; 70255570Strasz 71255570Strasz/* 72255570Strasz * Session state, negotiated by iscsid(8) and queried by iscsictl(8). 73255570Strasz */ 74255570Straszstruct iscsi_session_state { 75255570Strasz struct iscsi_session_conf iss_conf; 76255570Strasz unsigned int iss_id; 77255570Strasz char iss_target_alias[ISCSI_ALIAS_LEN]; 78255570Strasz int iss_header_digest; 79255570Strasz int iss_data_digest; 80255570Strasz int iss_max_data_segment_length; 81255570Strasz int iss_immediate_data; 82255570Strasz int iss_connected; 83255570Strasz char iss_reason[ISCSI_REASON_LEN]; 84255570Strasz int iss_spare[4]; 85255570Strasz}; 86255570Strasz 87255570Strasz/* 88255570Strasz * For use with iscsid(8). 89255570Strasz */ 90255570Strasz 91255570Straszstruct iscsi_daemon_request { 92255570Strasz unsigned int idr_session_id; 93255570Strasz struct iscsi_session_conf idr_conf; 94255570Strasz int idr_spare[4]; 95255570Strasz}; 96255570Strasz 97255570Straszstruct iscsi_daemon_handoff { 98255570Strasz unsigned int idh_session_id; 99255570Strasz int idh_socket; 100255570Strasz char idh_target_alias[ISCSI_ALIAS_LEN]; 101255570Strasz uint8_t idh_isid[6]; 102255570Strasz uint32_t idh_statsn; 103255570Strasz int idh_header_digest; 104255570Strasz int idh_data_digest; 105255570Strasz int idh_initial_r2t; 106255570Strasz int idh_immediate_data; 107255570Strasz size_t idh_max_data_segment_length; 108255570Strasz size_t idh_max_burst_length; 109255570Strasz size_t idh_first_burst_length; 110255570Strasz}; 111255570Strasz 112255570Straszstruct iscsi_daemon_fail { 113255570Strasz unsigned int idf_session_id; 114255570Strasz char idf_reason[ISCSI_REASON_LEN]; 115255570Strasz}; 116255570Strasz 117255570Strasz#define ISCSIDWAIT _IOR('I', 0x01, struct iscsi_daemon_request) 118255570Strasz#define ISCSIDHANDOFF _IOW('I', 0x02, struct iscsi_daemon_handoff) 119255570Strasz#define ISCSIDFAIL _IOW('I', 0x03, struct iscsi_daemon_fail) 120255570Strasz 121255570Strasz#ifdef ICL_KERNEL_PROXY 122255570Strasz 123255570Strasz/* 124255570Strasz * When ICL_KERNEL_PROXY is not defined, the iscsid(8) is responsible 125255570Strasz * for creating the socket, connecting, performing Login Phase using 126255570Strasz * socked in the usual userspace way, and then passing the socket file 127255570Strasz * descriptor to the kernel part using ISCSIDHANDOFF. 128255570Strasz * 129255570Strasz * When ICL_KERNEL_PROXY is defined, the iscsid(8) creates the session 130255570Strasz * using ISCSICONNECT, performs Login Phase using ISCSISEND/ISCSIRECEIVE 131255570Strasz * instead of read(2)/write(2), and then calls ISCSIDHANDOFF with 132255570Strasz * idh_socket set to 0. 133255570Strasz * 134255570Strasz * The purpose of ICL_KERNEL_PROXY is to workaround the fact that, 135255570Strasz * at this time, it's not possible to do iWARP (RDMA) in userspace. 136255570Strasz */ 137255570Strasz 138255570Straszstruct iscsi_daemon_connect { 139255570Strasz int idc_session_id; 140255570Strasz int idc_iser; 141255570Strasz int idc_domain; 142255570Strasz int idc_socktype; 143255570Strasz int idc_protocol; 144255570Strasz struct sockaddr *idc_from_addr; 145255570Strasz socklen_t idc_from_addrlen; 146255570Strasz struct sockaddr *idc_to_addr; 147255570Strasz socklen_t idc_to_addrlen; 148255570Strasz}; 149255570Strasz 150255570Straszstruct iscsi_daemon_send { 151255570Strasz int ids_session_id; 152255570Strasz void *ids_bhs; 153255570Strasz size_t ids_spare; 154255570Strasz void *ids_spare2; 155255570Strasz size_t ids_data_segment_len; 156255570Strasz void *ids_data_segment; 157255570Strasz}; 158255570Strasz 159255570Straszstruct iscsi_daemon_receive { 160255570Strasz int idr_session_id; 161255570Strasz void *idr_bhs; 162255570Strasz size_t idr_spare; 163255570Strasz void *idr_spare2; 164255570Strasz size_t idr_data_segment_len; 165255570Strasz void *idr_data_segment; 166255570Strasz}; 167255570Strasz 168255570Straszstruct iscsi_daemon_close { 169255570Strasz int idc_session_id; 170255570Strasz}; 171255570Strasz 172255570Strasz#define ISCSIDCONNECT _IOWR('I', 0x04, struct iscsi_daemon_connect) 173255570Strasz#define ISCSIDSEND _IOWR('I', 0x05, struct iscsi_daemon_send) 174255570Strasz#define ISCSIDRECEIVE _IOWR('I', 0x06, struct iscsi_daemon_receive) 175255570Strasz#define ISCSIDCLOSE _IOWR('I', 0x07, struct iscsi_daemon_close) 176255570Strasz 177255570Strasz#endif /* ICL_KERNEL_PROXY */ 178255570Strasz 179255570Strasz/* 180255570Strasz * For use with iscsictl(8). 181255570Strasz */ 182255570Strasz 183255570Straszstruct iscsi_session_add { 184255570Strasz struct iscsi_session_conf isa_conf; 185255570Strasz}; 186255570Strasz 187255570Straszstruct iscsi_session_remove { 188255570Strasz unsigned int isr_session_id; 189255570Strasz struct iscsi_session_conf isr_conf; 190255570Strasz}; 191255570Strasz 192255570Straszstruct iscsi_session_list { 193255570Strasz unsigned int isl_nentries; 194255570Strasz struct iscsi_session_state *isl_pstates; 195255570Strasz}; 196255570Strasz 197255570Strasz#define ISCSISADD _IOW('I', 0x11, struct iscsi_session_add) 198255570Strasz#define ISCSISREMOVE _IOW('I', 0x12, struct iscsi_session_remove) 199255570Strasz#define ISCSISLIST _IOWR('I', 0x13, struct iscsi_session_list) 200255570Strasz 201255570Strasz#endif /* !ISCSI_IOCTL_H */ 202