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: releng/10.3/sys/dev/iscsi/iscsi_ioctl.h 269065 2014-07-24 15:31:45Z mav $ 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; 94268703Smav uint8_t idr_isid[6]; 95268703Smav uint16_t idr_tsih; 96255739Strasz uint16_t idr_spare_cid; 97255570Strasz int idr_spare[4]; 98255570Strasz}; 99255570Strasz 100255570Straszstruct iscsi_daemon_handoff { 101255570Strasz unsigned int idh_session_id; 102255570Strasz int idh_socket; 103255570Strasz char idh_target_alias[ISCSI_ALIAS_LEN]; 104268703Smav uint8_t idh_spare_isid[6]; 105268703Smav uint16_t idh_tsih; 106268703Smav uint16_t idh_spare_cid; 107255570Strasz uint32_t idh_statsn; 108255570Strasz int idh_header_digest; 109255570Strasz int idh_data_digest; 110255570Strasz int idh_initial_r2t; 111255570Strasz int idh_immediate_data; 112255570Strasz size_t idh_max_data_segment_length; 113255570Strasz size_t idh_max_burst_length; 114255570Strasz size_t idh_first_burst_length; 115255739Strasz int idh_spare[4]; 116255570Strasz}; 117255570Strasz 118255570Straszstruct iscsi_daemon_fail { 119255570Strasz unsigned int idf_session_id; 120255570Strasz char idf_reason[ISCSI_REASON_LEN]; 121255739Strasz int idf_spare[4]; 122255570Strasz}; 123255570Strasz 124255570Strasz#define ISCSIDWAIT _IOR('I', 0x01, struct iscsi_daemon_request) 125255570Strasz#define ISCSIDHANDOFF _IOW('I', 0x02, struct iscsi_daemon_handoff) 126255570Strasz#define ISCSIDFAIL _IOW('I', 0x03, struct iscsi_daemon_fail) 127255570Strasz 128255570Strasz#ifdef ICL_KERNEL_PROXY 129255570Strasz 130255570Strasz/* 131255570Strasz * When ICL_KERNEL_PROXY is not defined, the iscsid(8) is responsible 132265526Strasz * for creating the socket, connecting, and performing Login Phase using 133265526Strasz * the socket in the usual userspace way, and then passing the socket 134265526Strasz * file descriptor to the kernel part using ISCSIDHANDOFF. 135255570Strasz * 136255570Strasz * When ICL_KERNEL_PROXY is defined, the iscsid(8) creates the session 137255570Strasz * using ISCSICONNECT, performs Login Phase using ISCSISEND/ISCSIRECEIVE 138255570Strasz * instead of read(2)/write(2), and then calls ISCSIDHANDOFF with 139255570Strasz * idh_socket set to 0. 140255570Strasz * 141255570Strasz * The purpose of ICL_KERNEL_PROXY is to workaround the fact that, 142255570Strasz * at this time, it's not possible to do iWARP (RDMA) in userspace. 143255570Strasz */ 144255570Strasz 145255570Straszstruct iscsi_daemon_connect { 146255570Strasz int idc_session_id; 147255570Strasz int idc_iser; 148255570Strasz int idc_domain; 149255570Strasz int idc_socktype; 150255570Strasz int idc_protocol; 151255570Strasz struct sockaddr *idc_from_addr; 152255570Strasz socklen_t idc_from_addrlen; 153255570Strasz struct sockaddr *idc_to_addr; 154255570Strasz socklen_t idc_to_addrlen; 155255739Strasz int idc_spare[4]; 156255570Strasz}; 157255570Strasz 158255570Straszstruct iscsi_daemon_send { 159255570Strasz int ids_session_id; 160255570Strasz void *ids_bhs; 161255570Strasz size_t ids_spare; 162255570Strasz void *ids_spare2; 163255570Strasz size_t ids_data_segment_len; 164255570Strasz void *ids_data_segment; 165265526Strasz int ids_spare3[4]; 166255570Strasz}; 167255570Strasz 168255570Straszstruct iscsi_daemon_receive { 169255570Strasz int idr_session_id; 170255570Strasz void *idr_bhs; 171255570Strasz size_t idr_spare; 172255570Strasz void *idr_spare2; 173255570Strasz size_t idr_data_segment_len; 174255570Strasz void *idr_data_segment; 175265526Strasz int idr_spare3[4]; 176255570Strasz}; 177255570Strasz 178255570Strasz#define ISCSIDCONNECT _IOWR('I', 0x04, struct iscsi_daemon_connect) 179255570Strasz#define ISCSIDSEND _IOWR('I', 0x05, struct iscsi_daemon_send) 180255570Strasz#define ISCSIDRECEIVE _IOWR('I', 0x06, struct iscsi_daemon_receive) 181255570Strasz 182255570Strasz#endif /* ICL_KERNEL_PROXY */ 183255570Strasz 184255570Strasz/* 185255570Strasz * For use with iscsictl(8). 186255570Strasz */ 187255570Strasz 188255570Straszstruct iscsi_session_add { 189255570Strasz struct iscsi_session_conf isa_conf; 190255739Strasz int isa_spare[4]; 191255570Strasz}; 192255570Strasz 193255570Straszstruct iscsi_session_remove { 194255570Strasz unsigned int isr_session_id; 195255570Strasz struct iscsi_session_conf isr_conf; 196255739Strasz int isr_spare[4]; 197255570Strasz}; 198255570Strasz 199255570Straszstruct iscsi_session_list { 200255570Strasz unsigned int isl_nentries; 201255570Strasz struct iscsi_session_state *isl_pstates; 202255739Strasz int isl_spare[4]; 203255570Strasz}; 204255570Strasz 205269065Smavstruct iscsi_session_modify { 206269065Smav unsigned int ism_session_id; 207269065Smav struct iscsi_session_conf ism_conf; 208269065Smav int ism_spare[4]; 209269065Smav}; 210269065Smav 211255570Strasz#define ISCSISADD _IOW('I', 0x11, struct iscsi_session_add) 212255570Strasz#define ISCSISREMOVE _IOW('I', 0x12, struct iscsi_session_remove) 213255570Strasz#define ISCSISLIST _IOWR('I', 0x13, struct iscsi_session_list) 214269065Smav#define ISCSISMODIFY _IOWR('I', 0x14, struct iscsi_session_modify) 215255570Strasz 216255570Strasz#endif /* !ISCSI_IOCTL_H */ 217