ctl_frontend_iscsi.h revision 268685
11573Srgrimes/*- 21573Srgrimes * Copyright (c) 2012 The FreeBSD Foundation 31573Srgrimes * All rights reserved. 41573Srgrimes * 51573Srgrimes * This software was developed by Edward Tomasz Napierala under sponsorship 61573Srgrimes * from the FreeBSD Foundation. 71573Srgrimes * 81573Srgrimes * Redistribution and use in source and binary forms, with or without 91573Srgrimes * modification, are permitted provided that the following conditions 101573Srgrimes * are met: 111573Srgrimes * 1. Redistributions of source code must retain the above copyright 121573Srgrimes * notice, this list of conditions and the following disclaimer. 131573Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 141573Srgrimes * notice, this list of conditions and the following disclaimer in the 151573Srgrimes * documentation and/or other materials provided with the distribution. 161573Srgrimes * 171573Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 181573Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191573Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201573Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 211573Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221573Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231573Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241573Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251573Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261573Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271573Srgrimes * SUCH DAMAGE. 281573Srgrimes * 2950476Speter * $FreeBSD: stable/10/sys/cam/ctl/ctl_frontend_iscsi.h 268685 2014-07-15 17:08:04Z mav $ 301573Srgrimes */ 31107021Smike 321573Srgrimes#ifndef CTL_FRONTEND_ISCSI_H 3379531Sru#define CTL_FRONTEND_ISCSI_H 341573Srgrimes 351573Srgrimes#define CFISCSI_TARGET_STATE_INVALID 0 361573Srgrimes#define CFISCSI_TARGET_STATE_ACTIVE 1 3759460Sphantom#define CFISCSI_TARGET_STATE_DYING 2 3859460Sphantom 391573Srgrimesstruct cfiscsi_target { 40107021Smike TAILQ_ENTRY(cfiscsi_target) ct_next; 411573Srgrimes uint32_t ct_luns[CTL_MAX_LUNS]; 421573Srgrimes struct cfiscsi_softc *ct_softc; 431573Srgrimes volatile u_int ct_refcount; 441573Srgrimes char ct_name[CTL_ISCSI_NAME_LEN]; 451573Srgrimes char ct_alias[CTL_ISCSI_ALIAS_LEN]; 461573Srgrimes int ct_state; 471573Srgrimes int ct_online; 48108028Sru struct ctl_port ct_port; 49108028Sru}; 50108028Sru 511573Srgrimesstruct cfiscsi_data_wait { 521573Srgrimes TAILQ_ENTRY(cfiscsi_data_wait) cdw_next; 531573Srgrimes union ctl_io *cdw_ctl_io; 541573Srgrimes uint32_t cdw_target_transfer_tag; 551573Srgrimes uint32_t cdw_initiator_task_tag; 561573Srgrimes int cdw_sg_index; 571573Srgrimes char *cdw_sg_addr; 581573Srgrimes size_t cdw_sg_len; 5938503Ssteve}; 6038503Ssteve 611573Srgrimes#define CFISCSI_SESSION_STATE_INVALID 0 621573Srgrimes#define CFISCSI_SESSION_STATE_BHS 1 631573Srgrimes#define CFISCSI_SESSION_STATE_AHS 2 641573Srgrimes#define CFISCSI_SESSION_STATE_HEADER_DIGEST 3 651573Srgrimes#define CFISCSI_SESSION_STATE_DATA 4 661573Srgrimes#define CFISCSI_SESSION_STATE_DATA_DIGEST 5 671573Srgrimes 681573Srgrimesstruct cfiscsi_session { 691573Srgrimes TAILQ_ENTRY(cfiscsi_session) cs_next; 701573Srgrimes struct mtx cs_lock; 711573Srgrimes struct icl_conn *cs_conn; 72108028Sru uint32_t cs_cmdsn; 73108028Sru uint32_t cs_statsn; 74108028Sru uint32_t cs_target_transfer_tag; 751573Srgrimes volatile u_int cs_outstanding_ctl_pdus; 761573Srgrimes TAILQ_HEAD(, cfiscsi_data_wait) cs_waiting_for_data_out; 771573Srgrimes struct cfiscsi_target *cs_target; 781573Srgrimes struct callout cs_callout; 7929908Smsmith int cs_timeout; 801573Srgrimes int cs_portal_group_tag; 811573Srgrimes struct cv cs_maintenance_cv; 821573Srgrimes bool cs_terminating; 831573Srgrimes size_t cs_max_data_segment_length; 841573Srgrimes size_t cs_max_burst_length; 851573Srgrimes bool cs_immediate_data; 861573Srgrimes char cs_initiator_name[CTL_ISCSI_NAME_LEN]; 871573Srgrimes char cs_initiator_addr[CTL_ISCSI_ADDR_LEN]; 881573Srgrimes char cs_initiator_alias[CTL_ISCSI_ALIAS_LEN]; 891573Srgrimes char cs_initiator_isid[6]; 901573Srgrimes char cs_initiator_id[CTL_ISCSI_NAME_LEN + 5 + 6 + 1]; 911573Srgrimes unsigned int cs_id; 921573Srgrimes int cs_ctl_initid; 931573Srgrimes#ifdef ICL_KERNEL_PROXY 941573Srgrimes struct sockaddr *cs_initiator_sa; 951573Srgrimes int cs_portal_id; 961573Srgrimes bool cs_login_phase; 971573Srgrimes bool cs_waiting_for_ctld; 981573Srgrimes struct cv cs_login_cv; 991573Srgrimes struct icl_pdu *cs_login_pdu; 1001573Srgrimes#endif 1011573Srgrimes}; 1021573Srgrimes 1031573Srgrimes#ifdef ICL_KERNEL_PROXY 1041573Srgrimesstruct icl_listen; 1051573Srgrimes#endif 1061573Srgrimes 107139253Skeramidastruct cfiscsi_softc { 108131504Sru struct mtx lock; 109131504Sru char port_name[32]; 11056501Salfred int online; 11156501Salfred unsigned int last_session_id; 11279754Sdd TAILQ_HEAD(, cfiscsi_target) targets; 1131573Srgrimes TAILQ_HEAD(, cfiscsi_session) sessions; 114139253Skeramida char ctl_initids[CTL_MAX_INIT_PER_PORT]; 11556501Salfred int max_initiators; 11656501Salfred#ifdef ICL_KERNEL_PROXY 1171573Srgrimes struct icl_listen *listener; 118139253Skeramida struct cv accept_cv; 119139186Skeramida#endif 1201573Srgrimes}; 1211573Srgrimes 1221573Srgrimes#endif /* !CTL_FRONTEND_ISCSI_H */ 1231573Srgrimes