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