xref: /titanic_51/usr/src/uts/common/sys/stmf.h (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
1*fcf3ce44SJohn Forte /*
2*fcf3ce44SJohn Forte  * CDDL HEADER START
3*fcf3ce44SJohn Forte  *
4*fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5*fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6*fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7*fcf3ce44SJohn Forte  *
8*fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10*fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11*fcf3ce44SJohn Forte  * and limitations under the License.
12*fcf3ce44SJohn Forte  *
13*fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14*fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16*fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17*fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18*fcf3ce44SJohn Forte  *
19*fcf3ce44SJohn Forte  * CDDL HEADER END
20*fcf3ce44SJohn Forte  */
21*fcf3ce44SJohn Forte /*
22*fcf3ce44SJohn Forte  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*fcf3ce44SJohn Forte  * Use is subject to license terms.
24*fcf3ce44SJohn Forte  */
25*fcf3ce44SJohn Forte #ifndef	_STMF_H
26*fcf3ce44SJohn Forte #define	_STMF_H
27*fcf3ce44SJohn Forte 
28*fcf3ce44SJohn Forte #include <sys/stmf_defines.h>
29*fcf3ce44SJohn Forte 
30*fcf3ce44SJohn Forte #ifdef	__cplusplus
31*fcf3ce44SJohn Forte extern "C" {
32*fcf3ce44SJohn Forte #endif
33*fcf3ce44SJohn Forte 
34*fcf3ce44SJohn Forte typedef enum stmf_struct_id {
35*fcf3ce44SJohn Forte 	STMF_STRUCT_LU_PROVIDER = 1,
36*fcf3ce44SJohn Forte 	STMF_STRUCT_PORT_PROVIDER,
37*fcf3ce44SJohn Forte 	STMF_STRUCT_STMF_LOCAL_PORT,
38*fcf3ce44SJohn Forte 	STMF_STRUCT_STMF_LU,
39*fcf3ce44SJohn Forte 	STMF_STRUCT_SCSI_SESSION,
40*fcf3ce44SJohn Forte 	STMF_STRUCT_SCSI_TASK,
41*fcf3ce44SJohn Forte 	STMF_STRUCT_DATA_BUF,
42*fcf3ce44SJohn Forte 	STMF_STRUCT_DBUF_STORE,
43*fcf3ce44SJohn Forte 	STMF_MAX_STRUCT_IDS
44*fcf3ce44SJohn Forte } stmf_struct_id_t;
45*fcf3ce44SJohn Forte 
46*fcf3ce44SJohn Forte /*
47*fcf3ce44SJohn Forte  * Provider callback commands
48*fcf3ce44SJohn Forte  */
49*fcf3ce44SJohn Forte #define	STMF_PROVIDER_DATA_UPDATED	0x01
50*fcf3ce44SJohn Forte 
51*fcf3ce44SJohn Forte /*
52*fcf3ce44SJohn Forte  * Provider callback flags
53*fcf3ce44SJohn Forte  */
54*fcf3ce44SJohn Forte #define	STMF_PCB_STMF_ONLINING		0x0001
55*fcf3ce44SJohn Forte #define	STMF_PCB_PREG_COMPLETE		0x0002
56*fcf3ce44SJohn Forte 
57*fcf3ce44SJohn Forte typedef void *data_seg_handle_t;
58*fcf3ce44SJohn Forte #define	STMF_MAX_LU_CACHE_NTASKS 16
59*fcf3ce44SJohn Forte 
60*fcf3ce44SJohn Forte #define	STMF_NO_HANDLE	0xffffffff
61*fcf3ce44SJohn Forte 
62*fcf3ce44SJohn Forte #define	COMPANY_ID_NONE			0xFFFFFFFF
63*fcf3ce44SJohn Forte #define	COMPANY_ID_SUN			0x00144F
64*fcf3ce44SJohn Forte 
65*fcf3ce44SJohn Forte typedef struct stmf_data_buf {
66*fcf3ce44SJohn Forte 	void		*db_stmf_private;
67*fcf3ce44SJohn Forte 	void		*db_port_private;
68*fcf3ce44SJohn Forte 	void		*db_lu_private;
69*fcf3ce44SJohn Forte 	uint32_t	db_buf_size;	/* Total size of this buffer */
70*fcf3ce44SJohn Forte 	uint32_t	db_data_size;	/* Intended xfer size of this buffer */
71*fcf3ce44SJohn Forte 	uint32_t	db_relative_offset;
72*fcf3ce44SJohn Forte 	uint16_t	db_sglist_length;
73*fcf3ce44SJohn Forte 	uint16_t	db_flags;	/* Direction, auto status etc */
74*fcf3ce44SJohn Forte 	stmf_status_t	db_xfer_status;
75*fcf3ce44SJohn Forte 	uint8_t		db_handle;	/* To track parallel buffers */
76*fcf3ce44SJohn Forte 	struct stmf_sglist_ent {
77*fcf3ce44SJohn Forte 		uint32_t	seg_length;
78*fcf3ce44SJohn Forte 		uint8_t		*seg_addr;
79*fcf3ce44SJohn Forte 	}		db_sglist[1];
80*fcf3ce44SJohn Forte } stmf_data_buf_t;
81*fcf3ce44SJohn Forte 
82*fcf3ce44SJohn Forte /*
83*fcf3ce44SJohn Forte  * db_flags
84*fcf3ce44SJohn Forte  */
85*fcf3ce44SJohn Forte #define	DB_DIRECTION_TO_RPORT		0x0001
86*fcf3ce44SJohn Forte #define	DB_DIRECTION_FROM_RPORT		0x0002
87*fcf3ce44SJohn Forte #define	DB_SEND_STATUS_GOOD		0x0004
88*fcf3ce44SJohn Forte #define	DB_STATUS_GOOD_SENT		0x0008
89*fcf3ce44SJohn Forte #define	DB_DONT_CACHE			0x0010
90*fcf3ce44SJohn Forte 
91*fcf3ce44SJohn Forte typedef struct scsi_task {
92*fcf3ce44SJohn Forte 	void		*task_stmf_private;
93*fcf3ce44SJohn Forte 	void		*task_port_private;
94*fcf3ce44SJohn Forte 
95*fcf3ce44SJohn Forte 	void		*task_lu_private;
96*fcf3ce44SJohn Forte 	struct stmf_scsi_session *task_session;
97*fcf3ce44SJohn Forte 	struct stmf_local_port *task_lport;
98*fcf3ce44SJohn Forte 	struct stmf_lu	*task_lu;
99*fcf3ce44SJohn Forte 	void		*task_lu_itl_handle;	/* Assigned by LU */
100*fcf3ce44SJohn Forte 
101*fcf3ce44SJohn Forte 	/* CMD information from initiator */
102*fcf3ce44SJohn Forte 	uint8_t		task_lun_no[8];
103*fcf3ce44SJohn Forte 	uint8_t		task_flags;		/* See def. for task flags */
104*fcf3ce44SJohn Forte 	uint8_t		task_priority;		/* As per SAM-3 */
105*fcf3ce44SJohn Forte 	uint8_t		task_mgmt_function;	/* If this is a TM request */
106*fcf3ce44SJohn Forte 	uint8_t		task_max_nbufs;
107*fcf3ce44SJohn Forte 	uint8_t		task_cur_nbufs;
108*fcf3ce44SJohn Forte 	uint8_t		task_csn_size;		/* cmd seq no size in bits */
109*fcf3ce44SJohn Forte 	uint16_t	task_additional_flags;
110*fcf3ce44SJohn Forte 	uint32_t	task_cmd_seq_no;
111*fcf3ce44SJohn Forte 	uint32_t	task_expected_xfer_length;
112*fcf3ce44SJohn Forte 	uint32_t	task_timeout;		/* In seconds */
113*fcf3ce44SJohn Forte 	uint16_t	task_ext_id;
114*fcf3ce44SJohn Forte 	uint16_t	task_cdb_length;
115*fcf3ce44SJohn Forte 	uint8_t		*task_cdb;
116*fcf3ce44SJohn Forte 
117*fcf3ce44SJohn Forte 	/* Fields to manage data phase */
118*fcf3ce44SJohn Forte 	uint32_t	task_cmd_xfer_length;	/* xfer len based on CDB */
119*fcf3ce44SJohn Forte 	uint32_t	task_nbytes_transferred;
120*fcf3ce44SJohn Forte 
121*fcf3ce44SJohn Forte 	/* Status Phase */
122*fcf3ce44SJohn Forte 	stmf_status_t	task_completion_status;
123*fcf3ce44SJohn Forte 	uint32_t	task_resid;
124*fcf3ce44SJohn Forte 	uint8_t		task_status_ctrl;	/* See def. for status ctrl */
125*fcf3ce44SJohn Forte 	uint8_t		task_scsi_status;
126*fcf3ce44SJohn Forte 	uint16_t	task_sense_length;
127*fcf3ce44SJohn Forte 	uint8_t		*task_sense_data;
128*fcf3ce44SJohn Forte 
129*fcf3ce44SJohn Forte 	/* Misc. task data */
130*fcf3ce44SJohn Forte 	void		*task_extended_cmd;
131*fcf3ce44SJohn Forte 
132*fcf3ce44SJohn Forte } scsi_task_t;
133*fcf3ce44SJohn Forte 
134*fcf3ce44SJohn Forte /*
135*fcf3ce44SJohn Forte  * Maximum expected transfer length.   Can also be used when the transfer
136*fcf3ce44SJohn Forte  * length is unknown when the task is allocated (e.g. SAS)
137*fcf3ce44SJohn Forte  */
138*fcf3ce44SJohn Forte 
139*fcf3ce44SJohn Forte #define	TASK_MAX_XFER_LENGTH	0xFFFFFFFF
140*fcf3ce44SJohn Forte 
141*fcf3ce44SJohn Forte /*
142*fcf3ce44SJohn Forte  * task_flags definitions.
143*fcf3ce44SJohn Forte  */
144*fcf3ce44SJohn Forte /*
145*fcf3ce44SJohn Forte  * If TF_INITIAL_BURST is set, the dbuf passed with new_task() contains
146*fcf3ce44SJohn Forte  * data from initial burst. Otherwise its just a buffer which the port
147*fcf3ce44SJohn Forte  * passed to the LU.
148*fcf3ce44SJohn Forte  */
149*fcf3ce44SJohn Forte #define	TF_INITIAL_BURST	0x80
150*fcf3ce44SJohn Forte /* Both READ_DATA and WRITE_DATA can be set for bidirectional xfers */
151*fcf3ce44SJohn Forte #define	TF_READ_DATA		0x40
152*fcf3ce44SJohn Forte #define	TF_WRITE_DATA		0x20
153*fcf3ce44SJohn Forte #define	TF_ATTR_MASK		0x07
154*fcf3ce44SJohn Forte #define	TF_ATTR_UNTAGGED	0x0
155*fcf3ce44SJohn Forte #define	TF_ATTR_SIMPLE_QUEUE	0x1
156*fcf3ce44SJohn Forte #define	TF_ATTR_ORDERED_QUEUE	0x2
157*fcf3ce44SJohn Forte #define	TF_ATTR_HEAD_OF_QUEUE	0x3
158*fcf3ce44SJohn Forte #define	TF_ATTR_ACA		0x4
159*fcf3ce44SJohn Forte 
160*fcf3ce44SJohn Forte /*
161*fcf3ce44SJohn Forte  * Task Management flags.
162*fcf3ce44SJohn Forte  */
163*fcf3ce44SJohn Forte #define	TM_NONE			0x00
164*fcf3ce44SJohn Forte #define	TM_ABORT_TASK		0x01
165*fcf3ce44SJohn Forte #define	TM_ABORT_TASK_SET	0x02
166*fcf3ce44SJohn Forte #define	TM_CLEAR_ACA		0x03
167*fcf3ce44SJohn Forte #define	TM_CLEAR_TASK_SET	0x04
168*fcf3ce44SJohn Forte #define	TM_LUN_RESET		0x05
169*fcf3ce44SJohn Forte #define	TM_TARGET_WARM_RESET	0x06
170*fcf3ce44SJohn Forte #define	TM_TARGET_COLD_RESET	0x07
171*fcf3ce44SJohn Forte #define	TM_TASK_REASSIGN	0x08
172*fcf3ce44SJohn Forte #define	TM_TARGET_RESET		0x09
173*fcf3ce44SJohn Forte #define	TM_QUERY_TASK		0x0A
174*fcf3ce44SJohn Forte 
175*fcf3ce44SJohn Forte /*
176*fcf3ce44SJohn Forte  * additional flags
177*fcf3ce44SJohn Forte  */
178*fcf3ce44SJohn Forte #define	TASK_AF_ENABLE_COMP_CONF	0x01
179*fcf3ce44SJohn Forte #define	TASK_AF_PORT_LOAD_HIGH		0x02
180*fcf3ce44SJohn Forte #define	TASK_AF_NO_EXPECTED_XFER_LENGTH	0x04
181*fcf3ce44SJohn Forte 
182*fcf3ce44SJohn Forte /*
183*fcf3ce44SJohn Forte  * scsi_task_t extension identifiers
184*fcf3ce44SJohn Forte  */
185*fcf3ce44SJohn Forte #define	STMF_TASK_EXT_NONE		0
186*fcf3ce44SJohn Forte 
187*fcf3ce44SJohn Forte /*
188*fcf3ce44SJohn Forte  * max_nbufs
189*fcf3ce44SJohn Forte  */
190*fcf3ce44SJohn Forte #define	STMF_BUFS_MAX		255
191*fcf3ce44SJohn Forte 
192*fcf3ce44SJohn Forte /*
193*fcf3ce44SJohn Forte  * Task status ctrl
194*fcf3ce44SJohn Forte  */
195*fcf3ce44SJohn Forte #define	TASK_SCTRL_OVER		1
196*fcf3ce44SJohn Forte #define	TASK_SCTRL_UNDER	2
197*fcf3ce44SJohn Forte 
198*fcf3ce44SJohn Forte /*
199*fcf3ce44SJohn Forte  * The flags used by I/O flow.
200*fcf3ce44SJohn Forte  */
201*fcf3ce44SJohn Forte #define	STMF_IOF_LU_DONE		0x0001
202*fcf3ce44SJohn Forte #define	STMF_IOF_LPORT_DONE		0x0002
203*fcf3ce44SJohn Forte 
204*fcf3ce44SJohn Forte /*
205*fcf3ce44SJohn Forte  * struct allocation flags
206*fcf3ce44SJohn Forte  */
207*fcf3ce44SJohn Forte #define	AF_FORCE_NOSLEEP	0x0001
208*fcf3ce44SJohn Forte 
209*fcf3ce44SJohn Forte typedef struct stmf_state_change_info {
210*fcf3ce44SJohn Forte 	uint64_t	st_rflags;	/* Reason behin this change */
211*fcf3ce44SJohn Forte 	char		*st_additional_info;
212*fcf3ce44SJohn Forte } stmf_state_change_info_t;
213*fcf3ce44SJohn Forte 
214*fcf3ce44SJohn Forte typedef struct stmf_change_status {
215*fcf3ce44SJohn Forte 	stmf_status_t	st_completion_status;
216*fcf3ce44SJohn Forte 	char		*st_additional_info;
217*fcf3ce44SJohn Forte } stmf_change_status_t;
218*fcf3ce44SJohn Forte 
219*fcf3ce44SJohn Forte /*
220*fcf3ce44SJohn Forte  * conditions causing or affecting the change.
221*fcf3ce44SJohn Forte  */
222*fcf3ce44SJohn Forte #define	STMF_RFLAG_USER_REQUEST		0x0001
223*fcf3ce44SJohn Forte #define	STMF_RFLAG_FATAL_ERROR		0x0002
224*fcf3ce44SJohn Forte #define	STMF_RFLAG_STAY_OFFLINED	0x0004
225*fcf3ce44SJohn Forte #define	STMF_RFLAG_RESET		0x0008
226*fcf3ce44SJohn Forte #define	STMF_RFLAG_COLLECT_DEBUG_DUMP	0x0010
227*fcf3ce44SJohn Forte #define	STMF_RFLAG_LU_ABORT		0x0020
228*fcf3ce44SJohn Forte #define	STMF_RFLAG_LPORT_ABORT		0x0040
229*fcf3ce44SJohn Forte 
230*fcf3ce44SJohn Forte #define	STMF_CHANGE_INFO_LEN		160
231*fcf3ce44SJohn Forte 
232*fcf3ce44SJohn Forte /*
233*fcf3ce44SJohn Forte  * cmds to stmf_abort entry point
234*fcf3ce44SJohn Forte  */
235*fcf3ce44SJohn Forte #define	STMF_QUEUE_TASK_ABORT		1
236*fcf3ce44SJohn Forte #define	STMF_REQUEUE_TASK_ABORT_LPORT	2
237*fcf3ce44SJohn Forte #define	STMF_REQUEUE_TASK_ABORT_LU	3
238*fcf3ce44SJohn Forte #define	STMF_QUEUE_ABORT_LU		4
239*fcf3ce44SJohn Forte 
240*fcf3ce44SJohn Forte /*
241*fcf3ce44SJohn Forte  * cmds to be used by stmf ctl
242*fcf3ce44SJohn Forte  */
243*fcf3ce44SJohn Forte #define	STMF_CMD_LU_OP			0x0100
244*fcf3ce44SJohn Forte #define	STMF_CMD_LPORT_OP		0x0200
245*fcf3ce44SJohn Forte #define	STMF_CMD_MASK			0x00ff
246*fcf3ce44SJohn Forte #define	STMF_CMD_ONLINE			0x0001
247*fcf3ce44SJohn Forte #define	STMF_CMD_OFFLINE		0x0002
248*fcf3ce44SJohn Forte #define	STMF_CMD_GET_STATUS		0x0003
249*fcf3ce44SJohn Forte #define	STMF_CMD_ONLINE_COMPLETE	0x0004
250*fcf3ce44SJohn Forte #define	STMF_CMD_OFFLINE_COMPLETE	0x0005
251*fcf3ce44SJohn Forte #define	STMF_ACK_ONLINE_COMPLETE	0x0006
252*fcf3ce44SJohn Forte #define	STMF_ACK_OFFLINE_COMPLETE	0x0007
253*fcf3ce44SJohn Forte 
254*fcf3ce44SJohn Forte #define	STMF_CMD_LU_ONLINE		(STMF_CMD_LU_OP | STMF_CMD_ONLINE)
255*fcf3ce44SJohn Forte #define	STMF_CMD_LU_OFFLINE		(STMF_CMD_LU_OP | STMF_CMD_OFFLINE)
256*fcf3ce44SJohn Forte #define	STMF_CMD_LPORT_ONLINE		(STMF_CMD_LPORT_OP | STMF_CMD_ONLINE)
257*fcf3ce44SJohn Forte #define	STMF_CMD_LPORT_OFFLINE		(STMF_CMD_LPORT_OP | STMF_CMD_OFFLINE)
258*fcf3ce44SJohn Forte #define	STMF_CMD_GET_LU_STATUS		(STMF_CMD_LU_OP | STMF_CMD_GET_STATUS)
259*fcf3ce44SJohn Forte #define	STMF_CMD_GET_LPORT_STATUS	\
260*fcf3ce44SJohn Forte 			(STMF_CMD_LPORT_OP | STMF_CMD_GET_STATUS)
261*fcf3ce44SJohn Forte #define	STMF_CMD_LU_ONLINE_COMPLETE	\
262*fcf3ce44SJohn Forte 			(STMF_CMD_LU_OP | STMF_CMD_ONLINE_COMPLETE)
263*fcf3ce44SJohn Forte #define	STMF_CMD_LPORT_ONLINE_COMPLETE	\
264*fcf3ce44SJohn Forte 			(STMF_CMD_LPORT_OP | STMF_CMD_ONLINE_COMPLETE)
265*fcf3ce44SJohn Forte #define	STMF_ACK_LU_ONLINE_COMPLETE	\
266*fcf3ce44SJohn Forte 			(STMF_CMD_LU_OP | STMF_ACK_ONLINE_COMPLETE)
267*fcf3ce44SJohn Forte #define	STMF_ACK_LPORT_ONLINE_COMPLETE	\
268*fcf3ce44SJohn Forte 			(STMF_CMD_LPORT_OP | STMF_ACK_ONLINE_COMPLETE)
269*fcf3ce44SJohn Forte #define	STMF_CMD_LU_OFFLINE_COMPLETE	\
270*fcf3ce44SJohn Forte 			(STMF_CMD_LU_OP | STMF_CMD_OFFLINE_COMPLETE)
271*fcf3ce44SJohn Forte #define	STMF_CMD_LPORT_OFFLINE_COMPLETE	\
272*fcf3ce44SJohn Forte 			(STMF_CMD_LPORT_OP | STMF_CMD_OFFLINE_COMPLETE)
273*fcf3ce44SJohn Forte #define	STMF_ACK_LU_OFFLINE_COMPLETE	\
274*fcf3ce44SJohn Forte 			(STMF_CMD_LU_OP | STMF_ACK_OFFLINE_COMPLETE)
275*fcf3ce44SJohn Forte #define	STMF_ACK_LPORT_OFFLINE_COMPLETE	\
276*fcf3ce44SJohn Forte 			(STMF_CMD_LPORT_OP | STMF_ACK_OFFLINE_COMPLETE)
277*fcf3ce44SJohn Forte /*
278*fcf3ce44SJohn Forte  * For LPORTs and LUs to create their own ctl cmds which dont
279*fcf3ce44SJohn Forte  * conflict with stmf ctl cmds.
280*fcf3ce44SJohn Forte  */
281*fcf3ce44SJohn Forte #define	STMF_LPORT_CTL_CMDS		0x1000
282*fcf3ce44SJohn Forte #define	STMF_LU_CTL_CMDS		0x2000
283*fcf3ce44SJohn Forte 
284*fcf3ce44SJohn Forte /*
285*fcf3ce44SJohn Forte  * Commands for various info routines.
286*fcf3ce44SJohn Forte  */
287*fcf3ce44SJohn Forte /* Command classifiers */
288*fcf3ce44SJohn Forte #define	SI_LPORT		0x1000000
289*fcf3ce44SJohn Forte #define	SI_STMF			0x2000000
290*fcf3ce44SJohn Forte #define	SI_LU			0x4000000
291*fcf3ce44SJohn Forte #define	SI_LPORT_FC		0x0000000
292*fcf3ce44SJohn Forte #define	SI_LPORT_ISCSI		0x0010000
293*fcf3ce44SJohn Forte #define	SI_LPORT_SAS		0x0020000
294*fcf3ce44SJohn Forte #define	SI_STMF_LU		0x0010000
295*fcf3ce44SJohn Forte #define	SI_STMF_LPORT		0x0020000
296*fcf3ce44SJohn Forte 
297*fcf3ce44SJohn Forte #define	SI_GET_CLASS(v)		((v) & 0xFF000000)
298*fcf3ce44SJohn Forte #define	SI_GET_SUBCLASS(v)	((v) & 0x00FF0000)
299*fcf3ce44SJohn Forte 
300*fcf3ce44SJohn Forte /* Commands for LPORT info routines */
301*fcf3ce44SJohn Forte /* XXX - Implement these. */
302*fcf3ce44SJohn Forte #if 0
303*fcf3ce44SJohn Forte #define	SI_LPORT_FC_PORTINFO		(SI_LPORT | SI_LPORT_FC | 1)
304*fcf3ce44SJohn Forte #define	SI_RPORT_FC_PORTINFO		(SI_LPORT | SI_LPORT_FC | 2)
305*fcf3ce44SJohn Forte #endif
306*fcf3ce44SJohn Forte 
307*fcf3ce44SJohn Forte /*
308*fcf3ce44SJohn Forte  * Events
309*fcf3ce44SJohn Forte  */
310*fcf3ce44SJohn Forte #define	STMF_EVENT_ALL			((int)-1)
311*fcf3ce44SJohn Forte #define	LPORT_EVENT_INITIAL_LUN_MAPPED	0
312*fcf3ce44SJohn Forte 
313*fcf3ce44SJohn Forte /*
314*fcf3ce44SJohn Forte  * This needs to go into common/ddi/sunddi.h
315*fcf3ce44SJohn Forte  */
316*fcf3ce44SJohn Forte #define	DDI_NT_STMF		"ddi_scsi_target:framework"
317*fcf3ce44SJohn Forte #define	DDI_NT_STMF_LP		"ddi_scsi_target:lu_provider"
318*fcf3ce44SJohn Forte #define	DDI_NT_STMF_PP		"ddi_scsi_target:port_provider"
319*fcf3ce44SJohn Forte 
320*fcf3ce44SJohn Forte /*
321*fcf3ce44SJohn Forte  * VPD page bits.
322*fcf3ce44SJohn Forte  */
323*fcf3ce44SJohn Forte #define	STMF_VPD_LU_ID		0x01
324*fcf3ce44SJohn Forte #define	STMF_VPD_TARGET_ID	0x02
325*fcf3ce44SJohn Forte #define	STMF_VPD_TP_GROUP	0x04
326*fcf3ce44SJohn Forte #define	STMF_VPD_RELATIVE_TP_ID	0x08
327*fcf3ce44SJohn Forte 
328*fcf3ce44SJohn Forte /*
329*fcf3ce44SJohn Forte  * Common macros to simplify coding
330*fcf3ce44SJohn Forte  */
331*fcf3ce44SJohn Forte #define	STMF_SEC2TICK(x_sec)	(drv_usectohz((x_sec) * 1000000))
332*fcf3ce44SJohn Forte 
333*fcf3ce44SJohn Forte void stmf_trace(caddr_t ident, const char *fmt, ...);
334*fcf3ce44SJohn Forte void *stmf_alloc(stmf_struct_id_t sid, int additional_size, int alloc_flags);
335*fcf3ce44SJohn Forte void stmf_free(void *struct_ptr);
336*fcf3ce44SJohn Forte struct scsi_task *stmf_task_alloc(struct stmf_local_port *lport,
337*fcf3ce44SJohn Forte     struct stmf_scsi_session *ss, uint8_t *lun, uint16_t cdb_length,
338*fcf3ce44SJohn Forte     uint16_t ext_id);
339*fcf3ce44SJohn Forte void stmf_post_task(scsi_task_t *task, stmf_data_buf_t *dbuf);
340*fcf3ce44SJohn Forte stmf_data_buf_t *stmf_alloc_dbuf(scsi_task_t *task, uint32_t size,
341*fcf3ce44SJohn Forte     uint32_t *pminsize, uint32_t flags);
342*fcf3ce44SJohn Forte void stmf_free_dbuf(scsi_task_t *task, stmf_data_buf_t *dbuf);
343*fcf3ce44SJohn Forte stmf_status_t stmf_xfer_data(scsi_task_t *task, stmf_data_buf_t *dbuf,
344*fcf3ce44SJohn Forte     uint32_t ioflags);
345*fcf3ce44SJohn Forte stmf_status_t stmf_send_scsi_status(scsi_task_t *task, uint32_t ioflags);
346*fcf3ce44SJohn Forte void stmf_data_xfer_done(scsi_task_t *task, stmf_data_buf_t *dbuf,
347*fcf3ce44SJohn Forte     uint32_t iof);
348*fcf3ce44SJohn Forte void stmf_send_status_done(scsi_task_t *task, stmf_status_t s, uint32_t iof);
349*fcf3ce44SJohn Forte void stmf_task_lu_done(scsi_task_t *task);
350*fcf3ce44SJohn Forte void stmf_abort(int abort_cmd, scsi_task_t *task, stmf_status_t s, void *arg);
351*fcf3ce44SJohn Forte void stmf_task_lu_aborted(scsi_task_t *task, stmf_status_t s, uint32_t iof);
352*fcf3ce44SJohn Forte void stmf_task_lport_aborted(scsi_task_t *task, stmf_status_t s, uint32_t iof);
353*fcf3ce44SJohn Forte stmf_status_t stmf_task_poll_lu(scsi_task_t *task, uint32_t timeout);
354*fcf3ce44SJohn Forte stmf_status_t stmf_task_poll_lport(scsi_task_t *task, uint32_t timeout);
355*fcf3ce44SJohn Forte stmf_status_t stmf_ctl(int cmd, void *obj, void *arg);
356*fcf3ce44SJohn Forte stmf_status_t stmf_register_itl_handle(struct stmf_lu *lu, uint8_t *lun,
357*fcf3ce44SJohn Forte     struct stmf_scsi_session *ss, uint64_t session_id, void *itl_handle);
358*fcf3ce44SJohn Forte stmf_status_t stmf_deregister_itl_handle(struct stmf_lu *lu, uint8_t *lun,
359*fcf3ce44SJohn Forte     struct stmf_scsi_session *ss, uint64_t session_id, void *itl_handle);
360*fcf3ce44SJohn Forte stmf_status_t stmf_deregister_all_lu_itl_handles(struct stmf_lu *lu);
361*fcf3ce44SJohn Forte stmf_status_t stmf_get_itl_handle(struct stmf_lu *lu, uint8_t *lun,
362*fcf3ce44SJohn Forte     struct stmf_scsi_session *ss, uint64_t session_id, void **itl_handle_retp);
363*fcf3ce44SJohn Forte stmf_data_buf_t *stmf_handle_to_buf(scsi_task_t *task, uint8_t h);
364*fcf3ce44SJohn Forte stmf_status_t stmf_lu_add_event(struct stmf_lu *lu, int eventid);
365*fcf3ce44SJohn Forte stmf_status_t stmf_lu_remove_event(struct stmf_lu *lu, int eventid);
366*fcf3ce44SJohn Forte stmf_status_t stmf_lport_add_event(struct stmf_local_port *lport, int eventid);
367*fcf3ce44SJohn Forte stmf_status_t stmf_lport_remove_event(struct stmf_local_port *lport,
368*fcf3ce44SJohn Forte     int eventid);
369*fcf3ce44SJohn Forte void stmf_wwn_to_devid_desc(struct scsi_devid_desc *sdid, uint8_t *wwn,
370*fcf3ce44SJohn Forte     uint8_t protocol_id);
371*fcf3ce44SJohn Forte stmf_status_t stmf_scsilib_uniq_lu_id(uint32_t company_id,
372*fcf3ce44SJohn Forte     struct scsi_devid_desc *lu_id);
373*fcf3ce44SJohn Forte void stmf_scsilib_send_status(scsi_task_t *task, uint8_t st, uint32_t saa);
374*fcf3ce44SJohn Forte uint32_t stmf_scsilib_prepare_vpd_page83(scsi_task_t *task, uint8_t *page,
375*fcf3ce44SJohn Forte 		uint32_t page_len, uint8_t byte0, uint32_t vpd_mask);
376*fcf3ce44SJohn Forte void stmf_scsilib_handle_report_tpgs(scsi_task_t *task, stmf_data_buf_t *dbuf);
377*fcf3ce44SJohn Forte void stmf_scsilib_handle_task_mgmt(scsi_task_t *task);
378*fcf3ce44SJohn Forte 
379*fcf3ce44SJohn Forte #ifdef	__cplusplus
380*fcf3ce44SJohn Forte }
381*fcf3ce44SJohn Forte #endif
382*fcf3ce44SJohn Forte 
383*fcf3ce44SJohn Forte #endif	/* _STMF_H */
384