ctl_frontend_iscsi.h revision 268682
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: stable/10/sys/cam/ctl/ctl_frontend_iscsi.h 268682 2014-07-15 17:05:11Z mav $
30255570Strasz */
31255570Strasz
32255570Strasz#ifndef CTL_FRONTEND_ISCSI_H
33255570Strasz#define	CTL_FRONTEND_ISCSI_H
34255570Strasz
35268682Smav#define CFISCSI_TARGET_STATE_INVALID	0
36268682Smav#define CFISCSI_TARGET_STATE_ACTIVE	1
37268682Smav#define CFISCSI_TARGET_STATE_DYING	2
38268682Smav
39255570Straszstruct cfiscsi_target {
40255570Strasz	TAILQ_ENTRY(cfiscsi_target)	ct_next;
41255570Strasz	int				ct_luns[CTL_MAX_LUNS];
42255570Strasz	struct cfiscsi_softc		*ct_softc;
43255570Strasz	volatile u_int			ct_refcount;
44255570Strasz	char				ct_name[CTL_ISCSI_NAME_LEN];
45255570Strasz	char				ct_alias[CTL_ISCSI_ALIAS_LEN];
46268682Smav	int				ct_state;
47268682Smav	int				ct_online;
48268682Smav	struct ctl_port			ct_port;
49255570Strasz};
50255570Strasz
51255570Straszstruct cfiscsi_data_wait {
52255570Strasz	TAILQ_ENTRY(cfiscsi_data_wait)	cdw_next;
53255570Strasz	union ctl_io			*cdw_ctl_io;
54255570Strasz	uint32_t			cdw_target_transfer_tag;
55255570Strasz	uint32_t			cdw_initiator_task_tag;
56255570Strasz	int				cdw_sg_index;
57255570Strasz	char				*cdw_sg_addr;
58255570Strasz	size_t				cdw_sg_len;
59255570Strasz};
60255570Strasz
61255570Strasz#define CFISCSI_SESSION_STATE_INVALID		0
62255570Strasz#define CFISCSI_SESSION_STATE_BHS		1
63255570Strasz#define CFISCSI_SESSION_STATE_AHS		2
64255570Strasz#define CFISCSI_SESSION_STATE_HEADER_DIGEST	3
65255570Strasz#define CFISCSI_SESSION_STATE_DATA		4
66255570Strasz#define CFISCSI_SESSION_STATE_DATA_DIGEST	5
67255570Strasz
68255570Straszstruct cfiscsi_session {
69255570Strasz	TAILQ_ENTRY(cfiscsi_session)	cs_next;
70255570Strasz	struct mtx			cs_lock;
71255570Strasz	struct icl_conn			*cs_conn;
72255570Strasz	uint32_t			cs_cmdsn;
73255570Strasz	uint32_t			cs_statsn;
74255570Strasz	uint32_t			cs_target_transfer_tag;
75255570Strasz	volatile u_int			cs_outstanding_ctl_pdus;
76255570Strasz	TAILQ_HEAD(, cfiscsi_data_wait)	cs_waiting_for_data_out;
77255570Strasz	struct cfiscsi_target		*cs_target;
78255570Strasz	struct callout			cs_callout;
79255570Strasz	int				cs_timeout;
80255570Strasz	int				cs_portal_group_tag;
81255570Strasz	struct cv			cs_maintenance_cv;
82268258Smav	bool				cs_terminating;
83255570Strasz	size_t				cs_max_data_segment_length;
84255570Strasz	size_t				cs_max_burst_length;
85255570Strasz	bool				cs_immediate_data;
86255570Strasz	char				cs_initiator_name[CTL_ISCSI_NAME_LEN];
87255570Strasz	char				cs_initiator_addr[CTL_ISCSI_ADDR_LEN];
88255570Strasz	char				cs_initiator_alias[CTL_ISCSI_ALIAS_LEN];
89255570Strasz	unsigned int			cs_id;
90255570Strasz	int				cs_ctl_initid;
91255570Strasz#ifdef ICL_KERNEL_PROXY
92265513Strasz	struct sockaddr			*cs_initiator_sa;
93265509Strasz	int				cs_portal_id;
94255570Strasz	bool				cs_login_phase;
95255570Strasz	bool				cs_waiting_for_ctld;
96255570Strasz	struct cv			cs_login_cv;
97255570Strasz	struct icl_pdu			*cs_login_pdu;
98255570Strasz#endif
99255570Strasz};
100255570Strasz
101255570Strasz#ifdef ICL_KERNEL_PROXY
102255570Straszstruct icl_listen;
103255570Strasz#endif
104255570Strasz
105255570Straszstruct cfiscsi_softc {
106255570Strasz	struct mtx			lock;
107255570Strasz	char				port_name[32];
108255570Strasz	int				online;
109255570Strasz	unsigned int			last_session_id;
110255570Strasz	TAILQ_HEAD(, cfiscsi_target)	targets;
111255570Strasz	TAILQ_HEAD(, cfiscsi_session)	sessions;
112255570Strasz	char				ctl_initids[CTL_MAX_INIT_PER_PORT];
113255570Strasz	int				max_initiators;
114255570Strasz#ifdef ICL_KERNEL_PROXY
115255570Strasz	struct icl_listen		*listener;
116255570Strasz	struct cv			accept_cv;
117255570Strasz#endif
118255570Strasz};
119255570Strasz
120255570Strasz#endif /* !CTL_FRONTEND_ISCSI_H */
121