]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/cam/ctl/ctl_frontend_iscsi.h
bsdinstall: remove VTOC8 partition scheme option
[FreeBSD/FreeBSD.git] / sys / cam / ctl / ctl_frontend_iscsi.h
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2012 The FreeBSD Foundation
5  *
6  * This software was developed by Edward Tomasz Napierala under sponsorship
7  * from the FreeBSD Foundation.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  * $FreeBSD$
31  */
32
33 #ifndef CTL_FRONTEND_ISCSI_H
34 #define CTL_FRONTEND_ISCSI_H
35
36 #define CFISCSI_TARGET_STATE_INVALID    0
37 #define CFISCSI_TARGET_STATE_ACTIVE     1
38 #define CFISCSI_TARGET_STATE_DYING      2
39
40 struct cfiscsi_target {
41         TAILQ_ENTRY(cfiscsi_target)     ct_next;
42         struct cfiscsi_softc            *ct_softc;
43         volatile u_int                  ct_refcount;
44         char                            ct_name[CTL_ISCSI_NAME_LEN];
45         char                            ct_alias[CTL_ISCSI_ALIAS_LEN];
46         uint16_t                        ct_tag;
47         int                             ct_state;
48         int                             ct_online;
49         int                             ct_target_id;
50         struct ctl_port                 ct_port;
51 };
52
53 struct cfiscsi_data_wait {
54         TAILQ_ENTRY(cfiscsi_data_wait)  cdw_next;
55         union ctl_io                    *cdw_ctl_io;
56         uint32_t                        cdw_target_transfer_tag;
57         uint32_t                        cdw_initiator_task_tag;
58         int                             cdw_sg_index;
59         char                            *cdw_sg_addr;
60         size_t                          cdw_sg_len;
61         uint32_t                        cdw_r2t_end;
62         uint32_t                        cdw_datasn;
63         void                            *cdw_icl_prv;
64 };
65
66 #define CFISCSI_SESSION_STATE_INVALID           0
67 #define CFISCSI_SESSION_STATE_BHS               1
68 #define CFISCSI_SESSION_STATE_AHS               2
69 #define CFISCSI_SESSION_STATE_HEADER_DIGEST     3
70 #define CFISCSI_SESSION_STATE_DATA              4
71 #define CFISCSI_SESSION_STATE_DATA_DIGEST       5
72
73 struct cfiscsi_session {
74         TAILQ_ENTRY(cfiscsi_session)    cs_next;
75         struct mtx                      cs_lock;
76         struct icl_conn                 *cs_conn;
77         uint32_t                        cs_cmdsn;
78         uint32_t                        cs_statsn;
79         uint32_t                        cs_target_transfer_tag;
80         volatile u_int                  cs_outstanding_ctl_pdus;
81         TAILQ_HEAD(, cfiscsi_data_wait) cs_waiting_for_data_out;
82         struct cfiscsi_target           *cs_target;
83         struct callout                  cs_callout;
84         int                             cs_timeout;
85         struct cv                       cs_maintenance_cv;
86         bool                            cs_terminating;
87         bool                            cs_handoff_in_progress;
88         bool                            cs_tasks_aborted;
89         int                             cs_max_recv_data_segment_length;
90         int                             cs_max_send_data_segment_length;
91         int                             cs_max_burst_length;
92         int                             cs_first_burst_length;
93         bool                            cs_immediate_data;
94         char                            cs_initiator_name[CTL_ISCSI_NAME_LEN];
95         char                            cs_initiator_addr[CTL_ISCSI_ADDR_LEN];
96         char                            cs_initiator_alias[CTL_ISCSI_ALIAS_LEN];
97         char                            cs_initiator_isid[6];
98         char                            cs_initiator_id[CTL_ISCSI_NAME_LEN + 5 + 6 + 1];
99         unsigned int                    cs_id;
100         int                             cs_ctl_initid;
101 #ifdef ICL_KERNEL_PROXY
102         struct sockaddr                 *cs_initiator_sa;
103         int                             cs_portal_id;
104         bool                            cs_login_phase;
105         bool                            cs_waiting_for_ctld;
106         struct cv                       cs_login_cv;
107         struct icl_pdu                  *cs_login_pdu;
108 #endif
109 };
110
111 #ifdef ICL_KERNEL_PROXY
112 struct icl_listen;
113 #endif
114
115 struct cfiscsi_softc {
116         struct mtx                      lock;
117         char                            port_name[32];
118         int                             online;
119         int                             last_target_id;
120         unsigned int                    last_session_id;
121         TAILQ_HEAD(, cfiscsi_target)    targets;
122         TAILQ_HEAD(, cfiscsi_session)   sessions;
123         struct cv                       sessions_cv;
124 #ifdef ICL_KERNEL_PROXY
125         struct icl_listen               *listener;
126         struct cv                       accept_cv;
127 #endif
128 };
129
130 #endif /* !CTL_FRONTEND_ISCSI_H */