ctl_frontend_iscsi.h revision 265509
1/*-
2 * Copyright (c) 2012 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Edward Tomasz Napierala under sponsorship
6 * from the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
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.
16 *
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
27 * SUCH DAMAGE.
28 *
29 * $FreeBSD: stable/10/sys/cam/ctl/ctl_frontend_iscsi.h 265509 2014-05-07 07:32:45Z trasz $
30 */
31
32#ifndef CTL_FRONTEND_ISCSI_H
33#define	CTL_FRONTEND_ISCSI_H
34
35struct cfiscsi_target {
36	TAILQ_ENTRY(cfiscsi_target)	ct_next;
37	int				ct_luns[CTL_MAX_LUNS];
38	struct cfiscsi_softc		*ct_softc;
39	volatile u_int			ct_refcount;
40	char				ct_name[CTL_ISCSI_NAME_LEN];
41	char				ct_alias[CTL_ISCSI_ALIAS_LEN];
42};
43
44struct cfiscsi_data_wait {
45	TAILQ_ENTRY(cfiscsi_data_wait)	cdw_next;
46	union ctl_io			*cdw_ctl_io;
47	uint32_t			cdw_target_transfer_tag;
48	uint32_t			cdw_initiator_task_tag;
49	int				cdw_sg_index;
50	char				*cdw_sg_addr;
51	size_t				cdw_sg_len;
52};
53
54#define CFISCSI_SESSION_STATE_INVALID		0
55#define CFISCSI_SESSION_STATE_BHS		1
56#define CFISCSI_SESSION_STATE_AHS		2
57#define CFISCSI_SESSION_STATE_HEADER_DIGEST	3
58#define CFISCSI_SESSION_STATE_DATA		4
59#define CFISCSI_SESSION_STATE_DATA_DIGEST	5
60
61struct cfiscsi_session {
62	TAILQ_ENTRY(cfiscsi_session)	cs_next;
63	struct mtx			cs_lock;
64	struct icl_conn			*cs_conn;
65	uint32_t			cs_cmdsn;
66	uint32_t			cs_statsn;
67	uint32_t			cs_target_transfer_tag;
68	volatile u_int			cs_outstanding_ctl_pdus;
69	TAILQ_HEAD(, cfiscsi_data_wait)	cs_waiting_for_data_out;
70	struct cfiscsi_target		*cs_target;
71	struct callout			cs_callout;
72	int				cs_timeout;
73	int				cs_portal_group_tag;
74	struct cv			cs_maintenance_cv;
75	int				cs_terminating;
76	size_t				cs_max_data_segment_length;
77	size_t				cs_max_burst_length;
78	bool				cs_immediate_data;
79	char				cs_initiator_name[CTL_ISCSI_NAME_LEN];
80	char				cs_initiator_addr[CTL_ISCSI_ADDR_LEN];
81	char				cs_initiator_alias[CTL_ISCSI_ALIAS_LEN];
82	unsigned int			cs_id;
83	int				cs_ctl_initid;
84#ifdef ICL_KERNEL_PROXY
85	int				cs_portal_id;
86	bool				cs_login_phase;
87	bool				cs_waiting_for_ctld;
88	struct cv			cs_login_cv;
89	struct icl_pdu			*cs_login_pdu;
90#endif
91};
92
93#ifdef ICL_KERNEL_PROXY
94struct icl_listen;
95#endif
96
97struct cfiscsi_softc {
98	struct ctl_frontend		fe;
99	struct mtx			lock;
100	char				port_name[32];
101	int				online;
102	unsigned int			last_session_id;
103	TAILQ_HEAD(, cfiscsi_target)	targets;
104	TAILQ_HEAD(, cfiscsi_session)	sessions;
105	char				ctl_initids[CTL_MAX_INIT_PER_PORT];
106	int				max_initiators;
107#ifdef ICL_KERNEL_PROXY
108	struct icl_listen		*listener;
109	struct cv			accept_cv;
110#endif
111};
112
113#endif /* !CTL_FRONTEND_ISCSI_H */
114