xref: /onnv-gate/usr/src/uts/common/sys/stmf.h (revision 12750:f559965e4a2f)
17836SJohn.Forte@Sun.COM /*
27836SJohn.Forte@Sun.COM  * CDDL HEADER START
37836SJohn.Forte@Sun.COM  *
47836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
57836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
67836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
77836SJohn.Forte@Sun.COM  *
87836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
107836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
117836SJohn.Forte@Sun.COM  * and limitations under the License.
127836SJohn.Forte@Sun.COM  *
137836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
147836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
167836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
177836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
187836SJohn.Forte@Sun.COM  *
197836SJohn.Forte@Sun.COM  * CDDL HEADER END
207836SJohn.Forte@Sun.COM  */
217836SJohn.Forte@Sun.COM /*
2212314SJames.Moore@Sun.COM  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
237836SJohn.Forte@Sun.COM  */
247836SJohn.Forte@Sun.COM #ifndef	_STMF_H
257836SJohn.Forte@Sun.COM #define	_STMF_H
267836SJohn.Forte@Sun.COM 
277836SJohn.Forte@Sun.COM #include <sys/stmf_defines.h>
287836SJohn.Forte@Sun.COM 
297836SJohn.Forte@Sun.COM #ifdef	__cplusplus
307836SJohn.Forte@Sun.COM extern "C" {
317836SJohn.Forte@Sun.COM #endif
327836SJohn.Forte@Sun.COM 
337836SJohn.Forte@Sun.COM typedef enum stmf_struct_id {
347836SJohn.Forte@Sun.COM 	STMF_STRUCT_LU_PROVIDER = 1,
357836SJohn.Forte@Sun.COM 	STMF_STRUCT_PORT_PROVIDER,
367836SJohn.Forte@Sun.COM 	STMF_STRUCT_STMF_LOCAL_PORT,
377836SJohn.Forte@Sun.COM 	STMF_STRUCT_STMF_LU,
387836SJohn.Forte@Sun.COM 	STMF_STRUCT_SCSI_SESSION,
397836SJohn.Forte@Sun.COM 	STMF_STRUCT_SCSI_TASK,
407836SJohn.Forte@Sun.COM 	STMF_STRUCT_DATA_BUF,
417836SJohn.Forte@Sun.COM 	STMF_STRUCT_DBUF_STORE,
427836SJohn.Forte@Sun.COM 	STMF_MAX_STRUCT_IDS
437836SJohn.Forte@Sun.COM } stmf_struct_id_t;
447836SJohn.Forte@Sun.COM 
457836SJohn.Forte@Sun.COM /*
467836SJohn.Forte@Sun.COM  * Provider callback commands
477836SJohn.Forte@Sun.COM  */
487836SJohn.Forte@Sun.COM #define	STMF_PROVIDER_DATA_UPDATED	0x01
497836SJohn.Forte@Sun.COM 
507836SJohn.Forte@Sun.COM /*
517836SJohn.Forte@Sun.COM  * Provider callback flags
527836SJohn.Forte@Sun.COM  */
537836SJohn.Forte@Sun.COM #define	STMF_PCB_STMF_ONLINING		0x0001
547836SJohn.Forte@Sun.COM #define	STMF_PCB_PREG_COMPLETE		0x0002
557836SJohn.Forte@Sun.COM 
567836SJohn.Forte@Sun.COM typedef void *data_seg_handle_t;
577836SJohn.Forte@Sun.COM #define	STMF_MAX_LU_CACHE_NTASKS 16
587836SJohn.Forte@Sun.COM 
597836SJohn.Forte@Sun.COM #define	STMF_NO_HANDLE	0xffffffff
607836SJohn.Forte@Sun.COM 
617836SJohn.Forte@Sun.COM #define	COMPANY_ID_NONE			0xFFFFFFFF
627836SJohn.Forte@Sun.COM #define	COMPANY_ID_SUN			0x00144F
637836SJohn.Forte@Sun.COM 
6412314SJames.Moore@Sun.COM /*
6512314SJames.Moore@Sun.COM  * The scatter/gather list buffer format is used in 2 different
6612314SJames.Moore@Sun.COM  * contexts within stmf:
6712314SJames.Moore@Sun.COM  * 1) supplied by the port provider that the LU provider uses to exchange
6812314SJames.Moore@Sun.COM  *    data with the backing store.
6912314SJames.Moore@Sun.COM  * 2) supplied by the LU provider that the port provider uses exchange
7012314SJames.Moore@Sun.COM  *    data with the host initiator.
7112314SJames.Moore@Sun.COM  * The second format is optionally supported by the port provided as
7212314SJames.Moore@Sun.COM  * indicated by the command task flags.
7312314SJames.Moore@Sun.COM  */
7412314SJames.Moore@Sun.COM 
7512314SJames.Moore@Sun.COM typedef struct stmf_sglist_ent {
7612314SJames.Moore@Sun.COM 	uint32_t	seg_length;
7712314SJames.Moore@Sun.COM 	uint8_t		*seg_addr;
7812314SJames.Moore@Sun.COM } stmf_sglist_ent_t;
7912314SJames.Moore@Sun.COM 
807836SJohn.Forte@Sun.COM typedef struct stmf_data_buf {
817836SJohn.Forte@Sun.COM 	void		*db_stmf_private;
827836SJohn.Forte@Sun.COM 	void		*db_port_private;
837836SJohn.Forte@Sun.COM 	void		*db_lu_private;
847836SJohn.Forte@Sun.COM 	uint32_t	db_buf_size;	/* Total size of this buffer */
857836SJohn.Forte@Sun.COM 	uint32_t	db_data_size;	/* Intended xfer size of this buffer */
867836SJohn.Forte@Sun.COM 	uint32_t	db_relative_offset;
877836SJohn.Forte@Sun.COM 	uint16_t	db_sglist_length;
887836SJohn.Forte@Sun.COM 	uint16_t	db_flags;	/* Direction, auto status etc */
897836SJohn.Forte@Sun.COM 	stmf_status_t	db_xfer_status;
907836SJohn.Forte@Sun.COM 	uint8_t		db_handle;	/* To track parallel buffers */
9111773STim.Szeto@Sun.COM 	hrtime_t	db_xfer_start_timestamp;
9212314SJames.Moore@Sun.COM 	stmf_sglist_ent_t db_sglist[1];	/* PP scatter/gather list */
937836SJohn.Forte@Sun.COM } stmf_data_buf_t;
947836SJohn.Forte@Sun.COM 
957836SJohn.Forte@Sun.COM /*
967836SJohn.Forte@Sun.COM  * db_flags
977836SJohn.Forte@Sun.COM  */
987836SJohn.Forte@Sun.COM #define	DB_DIRECTION_TO_RPORT		0x0001
997836SJohn.Forte@Sun.COM #define	DB_DIRECTION_FROM_RPORT		0x0002
1007836SJohn.Forte@Sun.COM #define	DB_SEND_STATUS_GOOD		0x0004
1017836SJohn.Forte@Sun.COM #define	DB_STATUS_GOOD_SENT		0x0008
1027836SJohn.Forte@Sun.COM #define	DB_DONT_CACHE			0x0010
1039087SZhong.Wang@Sun.COM #define	DB_DONT_REUSE			0x0020
10412314SJames.Moore@Sun.COM #define	DB_LU_DATA_BUF			0x0040
10512625SJohn.Forte@Sun.COM #define	DB_LPORT_XFER_ACTIVE		0x8000
1067836SJohn.Forte@Sun.COM 
1077836SJohn.Forte@Sun.COM typedef struct scsi_task {
1087836SJohn.Forte@Sun.COM 	void		*task_stmf_private;
1097836SJohn.Forte@Sun.COM 	void		*task_port_private;
1107836SJohn.Forte@Sun.COM 
1117836SJohn.Forte@Sun.COM 	void		*task_lu_private;
1127836SJohn.Forte@Sun.COM 	struct stmf_scsi_session *task_session;
1137836SJohn.Forte@Sun.COM 	struct stmf_local_port *task_lport;
1147836SJohn.Forte@Sun.COM 	struct stmf_lu	*task_lu;
1157836SJohn.Forte@Sun.COM 	void		*task_lu_itl_handle;	/* Assigned by LU */
1167836SJohn.Forte@Sun.COM 
1177836SJohn.Forte@Sun.COM 	/* CMD information from initiator */
1187836SJohn.Forte@Sun.COM 	uint8_t		task_lun_no[8];
1197836SJohn.Forte@Sun.COM 	uint8_t		task_flags;		/* See def. for task flags */
1207836SJohn.Forte@Sun.COM 	uint8_t		task_priority;		/* As per SAM-3 */
1217836SJohn.Forte@Sun.COM 	uint8_t		task_mgmt_function;	/* If this is a TM request */
1227836SJohn.Forte@Sun.COM 	uint8_t		task_max_nbufs;
1237836SJohn.Forte@Sun.COM 	uint8_t		task_cur_nbufs;
1247836SJohn.Forte@Sun.COM 	uint8_t		task_csn_size;		/* cmd seq no size in bits */
1257836SJohn.Forte@Sun.COM 	uint16_t	task_additional_flags;
1267836SJohn.Forte@Sun.COM 	uint32_t	task_cmd_seq_no;
1277836SJohn.Forte@Sun.COM 	uint32_t	task_expected_xfer_length;
1287836SJohn.Forte@Sun.COM 	uint32_t	task_timeout;		/* In seconds */
1297836SJohn.Forte@Sun.COM 	uint16_t	task_ext_id;
1307836SJohn.Forte@Sun.COM 	uint16_t	task_cdb_length;
1317836SJohn.Forte@Sun.COM 	uint8_t		*task_cdb;
1327836SJohn.Forte@Sun.COM 
1337836SJohn.Forte@Sun.COM 	/* Fields to manage data phase */
1347836SJohn.Forte@Sun.COM 	uint32_t	task_cmd_xfer_length;	/* xfer len based on CDB */
1357836SJohn.Forte@Sun.COM 	uint32_t	task_nbytes_transferred;
13612314SJames.Moore@Sun.COM 	uint32_t	task_max_xfer_len;	/* largest xfer allowed */
13712314SJames.Moore@Sun.COM 	uint32_t	task_1st_xfer_len;	/* 1st xfer hint */
13812314SJames.Moore@Sun.COM 	uint32_t	task_copy_threshold;	/* copy reduction threshold */
13912314SJames.Moore@Sun.COM 
1407836SJohn.Forte@Sun.COM 
1417836SJohn.Forte@Sun.COM 	/* Status Phase */
1427836SJohn.Forte@Sun.COM 	stmf_status_t	task_completion_status;
1437836SJohn.Forte@Sun.COM 	uint32_t	task_resid;
1447836SJohn.Forte@Sun.COM 	uint8_t		task_status_ctrl;	/* See def. for status ctrl */
1457836SJohn.Forte@Sun.COM 	uint8_t		task_scsi_status;
1467836SJohn.Forte@Sun.COM 	uint16_t	task_sense_length;
1477836SJohn.Forte@Sun.COM 	uint8_t		*task_sense_data;
1487836SJohn.Forte@Sun.COM 
1497836SJohn.Forte@Sun.COM 	/* Misc. task data */
1507836SJohn.Forte@Sun.COM 	void		*task_extended_cmd;
1517836SJohn.Forte@Sun.COM 
1527836SJohn.Forte@Sun.COM } scsi_task_t;
1537836SJohn.Forte@Sun.COM 
1547836SJohn.Forte@Sun.COM /*
1557836SJohn.Forte@Sun.COM  * Maximum expected transfer length.   Can also be used when the transfer
1567836SJohn.Forte@Sun.COM  * length is unknown when the task is allocated (e.g. SAS)
1577836SJohn.Forte@Sun.COM  */
1587836SJohn.Forte@Sun.COM 
1597836SJohn.Forte@Sun.COM #define	TASK_MAX_XFER_LENGTH	0xFFFFFFFF
1607836SJohn.Forte@Sun.COM 
1617836SJohn.Forte@Sun.COM /*
1627836SJohn.Forte@Sun.COM  * task_flags definitions.
1637836SJohn.Forte@Sun.COM  */
1647836SJohn.Forte@Sun.COM /*
1657836SJohn.Forte@Sun.COM  * If TF_INITIAL_BURST is set, the dbuf passed with new_task() contains
1667836SJohn.Forte@Sun.COM  * data from initial burst. Otherwise its just a buffer which the port
1677836SJohn.Forte@Sun.COM  * passed to the LU.
1687836SJohn.Forte@Sun.COM  */
1697836SJohn.Forte@Sun.COM #define	TF_INITIAL_BURST	0x80
1707836SJohn.Forte@Sun.COM /* Both READ_DATA and WRITE_DATA can be set for bidirectional xfers */
1717836SJohn.Forte@Sun.COM #define	TF_READ_DATA		0x40
1727836SJohn.Forte@Sun.COM #define	TF_WRITE_DATA		0x20
1737836SJohn.Forte@Sun.COM #define	TF_ATTR_MASK		0x07
1747836SJohn.Forte@Sun.COM #define	TF_ATTR_UNTAGGED	0x0
1757836SJohn.Forte@Sun.COM #define	TF_ATTR_SIMPLE_QUEUE	0x1
1767836SJohn.Forte@Sun.COM #define	TF_ATTR_ORDERED_QUEUE	0x2
1777836SJohn.Forte@Sun.COM #define	TF_ATTR_HEAD_OF_QUEUE	0x3
1787836SJohn.Forte@Sun.COM #define	TF_ATTR_ACA		0x4
1797836SJohn.Forte@Sun.COM 
1807836SJohn.Forte@Sun.COM /*
1817836SJohn.Forte@Sun.COM  * Task Management flags.
1827836SJohn.Forte@Sun.COM  */
1837836SJohn.Forte@Sun.COM #define	TM_NONE			0x00
1847836SJohn.Forte@Sun.COM #define	TM_ABORT_TASK		0x01
1857836SJohn.Forte@Sun.COM #define	TM_ABORT_TASK_SET	0x02
1867836SJohn.Forte@Sun.COM #define	TM_CLEAR_ACA		0x03
1877836SJohn.Forte@Sun.COM #define	TM_CLEAR_TASK_SET	0x04
1887836SJohn.Forte@Sun.COM #define	TM_LUN_RESET		0x05
1897836SJohn.Forte@Sun.COM #define	TM_TARGET_WARM_RESET	0x06
1907836SJohn.Forte@Sun.COM #define	TM_TARGET_COLD_RESET	0x07
1917836SJohn.Forte@Sun.COM #define	TM_TASK_REASSIGN	0x08
1927836SJohn.Forte@Sun.COM #define	TM_TARGET_RESET		0x09
1937836SJohn.Forte@Sun.COM #define	TM_QUERY_TASK		0x0A
1947836SJohn.Forte@Sun.COM 
1957836SJohn.Forte@Sun.COM /*
1967836SJohn.Forte@Sun.COM  * additional flags
1977836SJohn.Forte@Sun.COM  */
1987836SJohn.Forte@Sun.COM #define	TASK_AF_ENABLE_COMP_CONF	0x01
1997836SJohn.Forte@Sun.COM #define	TASK_AF_PORT_LOAD_HIGH		0x02
2007836SJohn.Forte@Sun.COM #define	TASK_AF_NO_EXPECTED_XFER_LENGTH	0x04
20112314SJames.Moore@Sun.COM /*
20212314SJames.Moore@Sun.COM  * PP sets this flag if it can process dbufs created by the LU.
20312314SJames.Moore@Sun.COM  */
20412314SJames.Moore@Sun.COM #define	TASK_AF_ACCEPT_LU_DBUF		0x08
2057836SJohn.Forte@Sun.COM 
2067836SJohn.Forte@Sun.COM /*
2077836SJohn.Forte@Sun.COM  * scsi_task_t extension identifiers
2087836SJohn.Forte@Sun.COM  */
2097836SJohn.Forte@Sun.COM #define	STMF_TASK_EXT_NONE		0
2107836SJohn.Forte@Sun.COM 
2117836SJohn.Forte@Sun.COM /*
2127836SJohn.Forte@Sun.COM  * max_nbufs
2137836SJohn.Forte@Sun.COM  */
2147836SJohn.Forte@Sun.COM #define	STMF_BUFS_MAX		255
2157836SJohn.Forte@Sun.COM 
2167836SJohn.Forte@Sun.COM /*
2177836SJohn.Forte@Sun.COM  * Task status ctrl
2187836SJohn.Forte@Sun.COM  */
2197836SJohn.Forte@Sun.COM #define	TASK_SCTRL_OVER		1
2207836SJohn.Forte@Sun.COM #define	TASK_SCTRL_UNDER	2
2217836SJohn.Forte@Sun.COM 
2227836SJohn.Forte@Sun.COM /*
2237836SJohn.Forte@Sun.COM  * The flags used by I/O flow.
2247836SJohn.Forte@Sun.COM  */
2257836SJohn.Forte@Sun.COM #define	STMF_IOF_LU_DONE		0x0001
2267836SJohn.Forte@Sun.COM #define	STMF_IOF_LPORT_DONE		0x0002
22711773STim.Szeto@Sun.COM #define	STMF_IOF_STATS_ONLY		0x0004
2287836SJohn.Forte@Sun.COM 
2297836SJohn.Forte@Sun.COM /*
2307836SJohn.Forte@Sun.COM  * struct allocation flags
2317836SJohn.Forte@Sun.COM  */
2327836SJohn.Forte@Sun.COM #define	AF_FORCE_NOSLEEP	0x0001
23312314SJames.Moore@Sun.COM #define	AF_DONTZERO		0x0002
2347836SJohn.Forte@Sun.COM 
2357836SJohn.Forte@Sun.COM typedef struct stmf_state_change_info {
23612314SJames.Moore@Sun.COM 	uint64_t	st_rflags;	/* Reason behind this change */
2377836SJohn.Forte@Sun.COM 	char		*st_additional_info;
2387836SJohn.Forte@Sun.COM } stmf_state_change_info_t;
2397836SJohn.Forte@Sun.COM 
2407836SJohn.Forte@Sun.COM typedef struct stmf_change_status {
2417836SJohn.Forte@Sun.COM 	stmf_status_t	st_completion_status;
2427836SJohn.Forte@Sun.COM 	char		*st_additional_info;
2437836SJohn.Forte@Sun.COM } stmf_change_status_t;
2447836SJohn.Forte@Sun.COM 
2457836SJohn.Forte@Sun.COM /*
2467836SJohn.Forte@Sun.COM  * conditions causing or affecting the change.
2477836SJohn.Forte@Sun.COM  */
2487836SJohn.Forte@Sun.COM #define	STMF_RFLAG_USER_REQUEST		0x0001
2497836SJohn.Forte@Sun.COM #define	STMF_RFLAG_FATAL_ERROR		0x0002
2507836SJohn.Forte@Sun.COM #define	STMF_RFLAG_STAY_OFFLINED	0x0004
2517836SJohn.Forte@Sun.COM #define	STMF_RFLAG_RESET		0x0008
2527836SJohn.Forte@Sun.COM #define	STMF_RFLAG_COLLECT_DEBUG_DUMP	0x0010
2537836SJohn.Forte@Sun.COM #define	STMF_RFLAG_LU_ABORT		0x0020
2547836SJohn.Forte@Sun.COM #define	STMF_RFLAG_LPORT_ABORT		0x0040
2557836SJohn.Forte@Sun.COM 
2567836SJohn.Forte@Sun.COM #define	STMF_CHANGE_INFO_LEN		160
2577836SJohn.Forte@Sun.COM 
2587836SJohn.Forte@Sun.COM /*
2597836SJohn.Forte@Sun.COM  * cmds to stmf_abort entry point
2607836SJohn.Forte@Sun.COM  */
2617836SJohn.Forte@Sun.COM #define	STMF_QUEUE_TASK_ABORT		1
2627836SJohn.Forte@Sun.COM #define	STMF_REQUEUE_TASK_ABORT_LPORT	2
2637836SJohn.Forte@Sun.COM #define	STMF_REQUEUE_TASK_ABORT_LU	3
2647836SJohn.Forte@Sun.COM #define	STMF_QUEUE_ABORT_LU		4
2657836SJohn.Forte@Sun.COM 
2667836SJohn.Forte@Sun.COM /*
2677836SJohn.Forte@Sun.COM  * cmds to be used by stmf ctl
2687836SJohn.Forte@Sun.COM  */
2697836SJohn.Forte@Sun.COM #define	STMF_CMD_LU_OP			0x0100
2707836SJohn.Forte@Sun.COM #define	STMF_CMD_LPORT_OP		0x0200
2717836SJohn.Forte@Sun.COM #define	STMF_CMD_MASK			0x00ff
2727836SJohn.Forte@Sun.COM #define	STMF_CMD_ONLINE			0x0001
2737836SJohn.Forte@Sun.COM #define	STMF_CMD_OFFLINE		0x0002
2747836SJohn.Forte@Sun.COM #define	STMF_CMD_GET_STATUS		0x0003
2757836SJohn.Forte@Sun.COM #define	STMF_CMD_ONLINE_COMPLETE	0x0004
2767836SJohn.Forte@Sun.COM #define	STMF_CMD_OFFLINE_COMPLETE	0x0005
2777836SJohn.Forte@Sun.COM #define	STMF_ACK_ONLINE_COMPLETE	0x0006
2787836SJohn.Forte@Sun.COM #define	STMF_ACK_OFFLINE_COMPLETE	0x0007
2797836SJohn.Forte@Sun.COM 
2807836SJohn.Forte@Sun.COM #define	STMF_CMD_LU_ONLINE		(STMF_CMD_LU_OP | STMF_CMD_ONLINE)
2817836SJohn.Forte@Sun.COM #define	STMF_CMD_LU_OFFLINE		(STMF_CMD_LU_OP | STMF_CMD_OFFLINE)
2827836SJohn.Forte@Sun.COM #define	STMF_CMD_LPORT_ONLINE		(STMF_CMD_LPORT_OP | STMF_CMD_ONLINE)
2837836SJohn.Forte@Sun.COM #define	STMF_CMD_LPORT_OFFLINE		(STMF_CMD_LPORT_OP | STMF_CMD_OFFLINE)
2847836SJohn.Forte@Sun.COM #define	STMF_CMD_GET_LU_STATUS		(STMF_CMD_LU_OP | STMF_CMD_GET_STATUS)
2857836SJohn.Forte@Sun.COM #define	STMF_CMD_GET_LPORT_STATUS	\
2867836SJohn.Forte@Sun.COM 			(STMF_CMD_LPORT_OP | STMF_CMD_GET_STATUS)
2877836SJohn.Forte@Sun.COM #define	STMF_CMD_LU_ONLINE_COMPLETE	\
2887836SJohn.Forte@Sun.COM 			(STMF_CMD_LU_OP | STMF_CMD_ONLINE_COMPLETE)
2897836SJohn.Forte@Sun.COM #define	STMF_CMD_LPORT_ONLINE_COMPLETE	\
2907836SJohn.Forte@Sun.COM 			(STMF_CMD_LPORT_OP | STMF_CMD_ONLINE_COMPLETE)
2917836SJohn.Forte@Sun.COM #define	STMF_ACK_LU_ONLINE_COMPLETE	\
2927836SJohn.Forte@Sun.COM 			(STMF_CMD_LU_OP | STMF_ACK_ONLINE_COMPLETE)
2937836SJohn.Forte@Sun.COM #define	STMF_ACK_LPORT_ONLINE_COMPLETE	\
2947836SJohn.Forte@Sun.COM 			(STMF_CMD_LPORT_OP | STMF_ACK_ONLINE_COMPLETE)
2957836SJohn.Forte@Sun.COM #define	STMF_CMD_LU_OFFLINE_COMPLETE	\
2967836SJohn.Forte@Sun.COM 			(STMF_CMD_LU_OP | STMF_CMD_OFFLINE_COMPLETE)
2977836SJohn.Forte@Sun.COM #define	STMF_CMD_LPORT_OFFLINE_COMPLETE	\
2987836SJohn.Forte@Sun.COM 			(STMF_CMD_LPORT_OP | STMF_CMD_OFFLINE_COMPLETE)
2997836SJohn.Forte@Sun.COM #define	STMF_ACK_LU_OFFLINE_COMPLETE	\
3007836SJohn.Forte@Sun.COM 			(STMF_CMD_LU_OP | STMF_ACK_OFFLINE_COMPLETE)
3017836SJohn.Forte@Sun.COM #define	STMF_ACK_LPORT_OFFLINE_COMPLETE	\
3027836SJohn.Forte@Sun.COM 			(STMF_CMD_LPORT_OP | STMF_ACK_OFFLINE_COMPLETE)
3037836SJohn.Forte@Sun.COM /*
3047836SJohn.Forte@Sun.COM  * For LPORTs and LUs to create their own ctl cmds which dont
3057836SJohn.Forte@Sun.COM  * conflict with stmf ctl cmds.
3067836SJohn.Forte@Sun.COM  */
3077836SJohn.Forte@Sun.COM #define	STMF_LPORT_CTL_CMDS		0x1000
3087836SJohn.Forte@Sun.COM #define	STMF_LU_CTL_CMDS		0x2000
3097836SJohn.Forte@Sun.COM 
3107836SJohn.Forte@Sun.COM /*
3117836SJohn.Forte@Sun.COM  * Commands for various info routines.
3127836SJohn.Forte@Sun.COM  */
3137836SJohn.Forte@Sun.COM /* Command classifiers */
3147836SJohn.Forte@Sun.COM #define	SI_LPORT		0x1000000
3157836SJohn.Forte@Sun.COM #define	SI_STMF			0x2000000
3167836SJohn.Forte@Sun.COM #define	SI_LU			0x4000000
3177836SJohn.Forte@Sun.COM #define	SI_LPORT_FC		0x0000000
3187836SJohn.Forte@Sun.COM #define	SI_LPORT_ISCSI		0x0010000
3197836SJohn.Forte@Sun.COM #define	SI_LPORT_SAS		0x0020000
3207836SJohn.Forte@Sun.COM #define	SI_STMF_LU		0x0010000
3217836SJohn.Forte@Sun.COM #define	SI_STMF_LPORT		0x0020000
3227836SJohn.Forte@Sun.COM 
3237836SJohn.Forte@Sun.COM #define	SI_GET_CLASS(v)		((v) & 0xFF000000)
3247836SJohn.Forte@Sun.COM #define	SI_GET_SUBCLASS(v)	((v) & 0x00FF0000)
3257836SJohn.Forte@Sun.COM 
3267836SJohn.Forte@Sun.COM /* Commands for LPORT info routines */
3277836SJohn.Forte@Sun.COM /* XXX - Implement these. */
3287836SJohn.Forte@Sun.COM #if 0
3297836SJohn.Forte@Sun.COM #define	SI_LPORT_FC_PORTINFO		(SI_LPORT | SI_LPORT_FC | 1)
3307836SJohn.Forte@Sun.COM #define	SI_RPORT_FC_PORTINFO		(SI_LPORT | SI_LPORT_FC | 2)
3317836SJohn.Forte@Sun.COM #endif
3327836SJohn.Forte@Sun.COM 
3337836SJohn.Forte@Sun.COM /*
3347836SJohn.Forte@Sun.COM  * Events
3357836SJohn.Forte@Sun.COM  */
3367836SJohn.Forte@Sun.COM #define	STMF_EVENT_ALL			((int)-1)
3377836SJohn.Forte@Sun.COM #define	LPORT_EVENT_INITIAL_LUN_MAPPED	0
3387836SJohn.Forte@Sun.COM 
3397836SJohn.Forte@Sun.COM /*
3407836SJohn.Forte@Sun.COM  * This needs to go into common/ddi/sunddi.h
3417836SJohn.Forte@Sun.COM  */
3427836SJohn.Forte@Sun.COM #define	DDI_NT_STMF		"ddi_scsi_target:framework"
3437836SJohn.Forte@Sun.COM #define	DDI_NT_STMF_LP		"ddi_scsi_target:lu_provider"
3447836SJohn.Forte@Sun.COM #define	DDI_NT_STMF_PP		"ddi_scsi_target:port_provider"
3457836SJohn.Forte@Sun.COM 
3467836SJohn.Forte@Sun.COM /*
3477836SJohn.Forte@Sun.COM  * VPD page bits.
3487836SJohn.Forte@Sun.COM  */
3497836SJohn.Forte@Sun.COM #define	STMF_VPD_LU_ID		0x01
3507836SJohn.Forte@Sun.COM #define	STMF_VPD_TARGET_ID	0x02
3517836SJohn.Forte@Sun.COM #define	STMF_VPD_TP_GROUP	0x04
3527836SJohn.Forte@Sun.COM #define	STMF_VPD_RELATIVE_TP_ID	0x08
3537836SJohn.Forte@Sun.COM 
3547836SJohn.Forte@Sun.COM /*
3557836SJohn.Forte@Sun.COM  * Common macros to simplify coding
3567836SJohn.Forte@Sun.COM  */
3577836SJohn.Forte@Sun.COM #define	STMF_SEC2TICK(x_sec)	(drv_usectohz((x_sec) * 1000000))
3587836SJohn.Forte@Sun.COM 
3597836SJohn.Forte@Sun.COM void stmf_trace(caddr_t ident, const char *fmt, ...);
3607836SJohn.Forte@Sun.COM void *stmf_alloc(stmf_struct_id_t sid, int additional_size, int alloc_flags);
3617836SJohn.Forte@Sun.COM void stmf_free(void *struct_ptr);
3627836SJohn.Forte@Sun.COM struct scsi_task *stmf_task_alloc(struct stmf_local_port *lport,
3637836SJohn.Forte@Sun.COM     struct stmf_scsi_session *ss, uint8_t *lun, uint16_t cdb_length,
3647836SJohn.Forte@Sun.COM     uint16_t ext_id);
3657836SJohn.Forte@Sun.COM void stmf_post_task(scsi_task_t *task, stmf_data_buf_t *dbuf);
3667836SJohn.Forte@Sun.COM stmf_data_buf_t *stmf_alloc_dbuf(scsi_task_t *task, uint32_t size,
3677836SJohn.Forte@Sun.COM     uint32_t *pminsize, uint32_t flags);
3687836SJohn.Forte@Sun.COM void stmf_free_dbuf(scsi_task_t *task, stmf_data_buf_t *dbuf);
36912314SJames.Moore@Sun.COM stmf_status_t stmf_setup_dbuf(scsi_task_t *task, stmf_data_buf_t *dbuf,
37012314SJames.Moore@Sun.COM     uint32_t flags);
37112314SJames.Moore@Sun.COM void stmf_teardown_dbuf(scsi_task_t *task, stmf_data_buf_t *dbuf);
3727836SJohn.Forte@Sun.COM stmf_status_t stmf_xfer_data(scsi_task_t *task, stmf_data_buf_t *dbuf,
3737836SJohn.Forte@Sun.COM     uint32_t ioflags);
3747836SJohn.Forte@Sun.COM stmf_status_t stmf_send_scsi_status(scsi_task_t *task, uint32_t ioflags);
3757836SJohn.Forte@Sun.COM void stmf_data_xfer_done(scsi_task_t *task, stmf_data_buf_t *dbuf,
3767836SJohn.Forte@Sun.COM     uint32_t iof);
3777836SJohn.Forte@Sun.COM void stmf_send_status_done(scsi_task_t *task, stmf_status_t s, uint32_t iof);
3787836SJohn.Forte@Sun.COM void stmf_task_lu_done(scsi_task_t *task);
3797836SJohn.Forte@Sun.COM void stmf_abort(int abort_cmd, scsi_task_t *task, stmf_status_t s, void *arg);
3807836SJohn.Forte@Sun.COM void stmf_task_lu_aborted(scsi_task_t *task, stmf_status_t s, uint32_t iof);
3817836SJohn.Forte@Sun.COM void stmf_task_lport_aborted(scsi_task_t *task, stmf_status_t s, uint32_t iof);
3827836SJohn.Forte@Sun.COM stmf_status_t stmf_task_poll_lu(scsi_task_t *task, uint32_t timeout);
3837836SJohn.Forte@Sun.COM stmf_status_t stmf_task_poll_lport(scsi_task_t *task, uint32_t timeout);
3847836SJohn.Forte@Sun.COM stmf_status_t stmf_ctl(int cmd, void *obj, void *arg);
3857836SJohn.Forte@Sun.COM stmf_status_t stmf_register_itl_handle(struct stmf_lu *lu, uint8_t *lun,
3867836SJohn.Forte@Sun.COM     struct stmf_scsi_session *ss, uint64_t session_id, void *itl_handle);
3877836SJohn.Forte@Sun.COM stmf_status_t stmf_deregister_itl_handle(struct stmf_lu *lu, uint8_t *lun,
3887836SJohn.Forte@Sun.COM     struct stmf_scsi_session *ss, uint64_t session_id, void *itl_handle);
3897836SJohn.Forte@Sun.COM stmf_status_t stmf_deregister_all_lu_itl_handles(struct stmf_lu *lu);
3907836SJohn.Forte@Sun.COM stmf_status_t stmf_get_itl_handle(struct stmf_lu *lu, uint8_t *lun,
3917836SJohn.Forte@Sun.COM     struct stmf_scsi_session *ss, uint64_t session_id, void **itl_handle_retp);
3927836SJohn.Forte@Sun.COM stmf_data_buf_t *stmf_handle_to_buf(scsi_task_t *task, uint8_t h);
3937836SJohn.Forte@Sun.COM stmf_status_t stmf_lu_add_event(struct stmf_lu *lu, int eventid);
3947836SJohn.Forte@Sun.COM stmf_status_t stmf_lu_remove_event(struct stmf_lu *lu, int eventid);
3957836SJohn.Forte@Sun.COM stmf_status_t stmf_lport_add_event(struct stmf_local_port *lport, int eventid);
3967836SJohn.Forte@Sun.COM stmf_status_t stmf_lport_remove_event(struct stmf_local_port *lport,
3977836SJohn.Forte@Sun.COM     int eventid);
3987836SJohn.Forte@Sun.COM void stmf_wwn_to_devid_desc(struct scsi_devid_desc *sdid, uint8_t *wwn,
3997836SJohn.Forte@Sun.COM     uint8_t protocol_id);
4007836SJohn.Forte@Sun.COM stmf_status_t stmf_scsilib_uniq_lu_id(uint32_t company_id,
4017836SJohn.Forte@Sun.COM     struct scsi_devid_desc *lu_id);
40210765SJohn.Forte@Sun.COM stmf_status_t stmf_scsilib_uniq_lu_id2(uint32_t company_id, uint32_t host_id,
40310765SJohn.Forte@Sun.COM     struct scsi_devid_desc *lu_id);
4047836SJohn.Forte@Sun.COM void stmf_scsilib_send_status(scsi_task_t *task, uint8_t st, uint32_t saa);
4057836SJohn.Forte@Sun.COM uint32_t stmf_scsilib_prepare_vpd_page83(scsi_task_t *task, uint8_t *page,
4067836SJohn.Forte@Sun.COM 		uint32_t page_len, uint8_t byte0, uint32_t vpd_mask);
4079585STim.Szeto@Sun.COM uint16_t stmf_scsilib_get_lport_rtid(struct scsi_devid_desc *devid);
4089585STim.Szeto@Sun.COM struct scsi_devid_desc *stmf_scsilib_get_devid_desc(uint16_t rtpid);
4097836SJohn.Forte@Sun.COM void stmf_scsilib_handle_report_tpgs(scsi_task_t *task, stmf_data_buf_t *dbuf);
4107836SJohn.Forte@Sun.COM void stmf_scsilib_handle_task_mgmt(scsi_task_t *task);
4117836SJohn.Forte@Sun.COM 
412*12750SNattuvetty.Bhavyan@Sun.COM struct stmf_remote_port *stmf_scsilib_devid_to_remote_port(
413*12750SNattuvetty.Bhavyan@Sun.COM     struct scsi_devid_desc *);
414*12750SNattuvetty.Bhavyan@Sun.COM boolean_t stmf_scsilib_tptid_validate(struct scsi_transport_id *,
415*12750SNattuvetty.Bhavyan@Sun.COM     uint32_t, uint16_t *);
416*12750SNattuvetty.Bhavyan@Sun.COM boolean_t stmf_scsilib_tptid_compare(struct scsi_transport_id *,
417*12750SNattuvetty.Bhavyan@Sun.COM     struct scsi_transport_id *);
418*12750SNattuvetty.Bhavyan@Sun.COM struct stmf_remote_port *stmf_remote_port_alloc(uint16_t);
419*12750SNattuvetty.Bhavyan@Sun.COM void stmf_remote_port_free(struct stmf_remote_port *);
4207836SJohn.Forte@Sun.COM #ifdef	__cplusplus
4217836SJohn.Forte@Sun.COM }
4227836SJohn.Forte@Sun.COM #endif
4237836SJohn.Forte@Sun.COM 
4247836SJohn.Forte@Sun.COM #endif	/* _STMF_H */
425