2 * Copyright (c) 2012 The FreeBSD Foundation
5 * This software was developed by Edward Tomasz Napierala under sponsorship
6 * from the FreeBSD Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #ifndef CTL_FRONTEND_ISCSI_H
33 #define CTL_FRONTEND_ISCSI_H
35 #define CFISCSI_TARGET_STATE_INVALID 0
36 #define CFISCSI_TARGET_STATE_ACTIVE 1
37 #define CFISCSI_TARGET_STATE_DYING 2
39 struct cfiscsi_target {
40 TAILQ_ENTRY(cfiscsi_target) ct_next;
41 struct cfiscsi_softc *ct_softc;
42 volatile u_int ct_refcount;
43 char ct_name[CTL_ISCSI_NAME_LEN];
44 char ct_alias[CTL_ISCSI_ALIAS_LEN];
49 struct ctl_port ct_port;
52 struct cfiscsi_data_wait {
53 TAILQ_ENTRY(cfiscsi_data_wait) cdw_next;
54 union ctl_io *cdw_ctl_io;
55 uint32_t cdw_target_transfer_tag;
56 uint32_t cdw_initiator_task_tag;
65 #define CFISCSI_SESSION_STATE_INVALID 0
66 #define CFISCSI_SESSION_STATE_BHS 1
67 #define CFISCSI_SESSION_STATE_AHS 2
68 #define CFISCSI_SESSION_STATE_HEADER_DIGEST 3
69 #define CFISCSI_SESSION_STATE_DATA 4
70 #define CFISCSI_SESSION_STATE_DATA_DIGEST 5
72 struct cfiscsi_session {
73 TAILQ_ENTRY(cfiscsi_session) cs_next;
75 struct icl_conn *cs_conn;
78 uint32_t cs_target_transfer_tag;
79 volatile u_int cs_outstanding_ctl_pdus;
80 TAILQ_HEAD(, cfiscsi_data_wait) cs_waiting_for_data_out;
81 struct cfiscsi_target *cs_target;
82 struct callout cs_callout;
84 struct cv cs_maintenance_cv;
86 bool cs_tasks_aborted;
87 size_t cs_max_data_segment_length;
88 size_t cs_max_burst_length;
89 size_t cs_first_burst_length;
90 bool cs_immediate_data;
91 char cs_initiator_name[CTL_ISCSI_NAME_LEN];
92 char cs_initiator_addr[CTL_ISCSI_ADDR_LEN];
93 char cs_initiator_alias[CTL_ISCSI_ALIAS_LEN];
94 char cs_initiator_isid[6];
95 char cs_initiator_id[CTL_ISCSI_NAME_LEN + 5 + 6 + 1];
98 #ifdef ICL_KERNEL_PROXY
99 struct sockaddr *cs_initiator_sa;
102 bool cs_waiting_for_ctld;
103 struct cv cs_login_cv;
104 struct icl_pdu *cs_login_pdu;
108 #ifdef ICL_KERNEL_PROXY
112 struct cfiscsi_softc {
117 unsigned int last_session_id;
118 TAILQ_HEAD(, cfiscsi_target) targets;
119 TAILQ_HEAD(, cfiscsi_session) sessions;
120 struct cv sessions_cv;
121 #ifdef ICL_KERNEL_PROXY
122 struct icl_listen *listener;
127 #endif /* !CTL_FRONTEND_ISCSI_H */