xref: /titanic_41/usr/src/uts/sun/sys/scsi/adapters/fascmd.h (revision 8d483882aa3390058094b043f3d62187b5d1de03)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1996-2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_SYS_SCSI_ADAPTERS_FASCMD_H
28 #define	_SYS_SCSI_ADAPTERS_FASCMD_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/note.h>
33 #include <sys/isa_defs.h>
34 #include <sys/scsi/scsi_types.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * The transport layer deals with things in terms of the following structure.
42  * Note	that the target	driver's view of things	is the scsi_pkt	that is
43  * enfolded as the first element of the	following structure.
44  *
45  * the preferred the cdb size is 12. fas is a scsi2 HBA driver and
46  * rarely needs 16 byte cdb's
47  */
48 
49 /*
50  * preferred pkt_private length in 64-bit quantities
51  */
52 #ifdef	_LP64
53 #define	PKT_PRIV_SIZE	2
54 #define	PKT_PRIV_LEN	16	/* in bytes */
55 #else /* _ILP32 */
56 #define	PKT_PRIV_SIZE	1
57 #define	PKT_PRIV_LEN	8	/* in bytes */
58 #endif
59 
60 
61 #define	PKT2CMD(pkt)		((struct fas_cmd *)(pkt)->pkt_ha_private)
62 #define	CMD2PKT(sp)		((sp)->cmd_pkt)
63 
64 #define	EXTCMD_SIZE (sizeof (struct fas_cmd) + sizeof (struct scsi_pkt))
65 #define	EXTCMDS_STATUS_SIZE (sizeof (struct scsi_arq_status))
66 
67 struct fas_cmd {
68 	struct scsi_pkt		*cmd_pkt;	/* the generic packet itself */
69 	struct fas_cmd		*cmd_forw;	/* ready fifo que link */
70 	uchar_t			*cmd_cdbp;	/* active command pointer */
71 
72 	uint32_t		cmd_data_count;	/* aggregate data count */
73 	uint32_t		cmd_cur_addr;	/* current dma address */
74 
75 	ushort_t		cmd_qfull_retries;
76 
77 	ushort_t		cmd_nwin;	/* number of windows */
78 	ushort_t		cmd_cur_win;	/* current window */
79 
80 	ushort_t		cmd_saved_win;	/* saved window */
81 	uint32_t		cmd_saved_data_count; /* saved aggr. count */
82 	uint32_t		cmd_saved_cur_addr; /* saved virt address */
83 	int			cmd_pkt_flags;	/* copy	of pkt_flags */
84 
85 	ddi_dma_handle_t	cmd_dmahandle;	/* dma handle */
86 	ddi_dma_cookie_t	cmd_dmacookie;	/* current dma cookie */
87 	uint32_t		cmd_dmacount;	/* total xfer count */
88 
89 	uchar_t			cmd_cdb[CDB_SIZE]; /* 12 byte cdb */
90 	uint_t			cmd_flags;	/* private flags */
91 	struct scsi_arq_status	cmd_scb;
92 	uint_t			cmd_scblen;	/* length of scb */
93 	uchar_t			cmd_slot;
94 	uchar_t			cmd_age;	/* cmd age (tagged queing) */
95 	uint_t			cmd_cdblen;	/* length of cdb */
96 	uint64_t		cmd_pkt_private[PKT_PRIV_SIZE];
97 	uint_t			cmd_privlen;	/* length of tgt private */
98 	uchar_t			cmd_tag[2];	/* command tag */
99 	uchar_t			cmd_actual_cdblen; /* length of	cdb */
100 };
101 
102 _NOTE(SCHEME_PROTECTS_DATA("unique per pkt", fas_cmd))
103 
104 /*
105  * private data	for arq	pkt
106  */
107 struct arq_private_data	{
108 	struct buf	*arq_save_bp;
109 	struct fas_cmd	*arq_save_sp;
110 };
111 
112 /*
113  * A note about	the cmd_cdb && cmd_scb structures:
114  *
115  *	If the command allocation requested exceeds the	size of	CDB_SIZE,
116  *	the cdb	will be	allocated outside this structure (via kmem_zalloc)
117  *	The same applies to cmd_scb.
118  */
119 
120 /*
121  * These are the defined flags for this	structure.
122  */
123 #define	CFLAG_CMDDISC		0x0001	/* cmd currently disconnected */
124 #define	CFLAG_WATCH		0x0002	/* watchdog time for this command */
125 #define	CFLAG_FINISHED		0x0004	/* command completed */
126 #define	CFLAG_CHKSEG		0x0008	/* check cmd_data within seg */
127 #define	CFLAG_COMPLETED		0x0010	/* completion routine called */
128 #define	CFLAG_PREPARED		0x0020	/* pkt has been	init'ed	*/
129 #define	CFLAG_IN_TRANSPORT	0x0040	/* in use by host adapter driver */
130 #define	CFLAG_RESTORE_PTRS	0x0080	/* implicit restore ptr on reconnect */
131 #define	CFLAG_TRANFLAG		0x00ff	/* covers transport part of flags */
132 #define	CFLAG_CMDPROXY		0x000100 /* cmd	is a 'proxy' command */
133 #define	CFLAG_CMDARQ		0x000200 /* cmd	is a 'rqsense' command */
134 #define	CFLAG_DMAVALID		0x000400 /* dma	mapping	valid */
135 #define	CFLAG_DMASEND		0x000800 /* data	is going 'out' */
136 #define	CFLAG_CMDIOPB		0x001000 /* this	is an 'iopb' packet */
137 #define	CFLAG_CDBEXTERN		0x002000 /* cdb	kmem_alloc'd */
138 #define	CFLAG_SCBEXTERN		0x004000 /* scb	kmem_alloc'd */
139 #define	CFLAG_FREE		0x008000 /* packet is on	free list */
140 #define	CFLAG_PRIVEXTERN	0x020000 /* target private kmem_alloc'd	*/
141 #define	CFLAG_DMA_PARTIAL	0x040000 /* partial xfer OK */
142 
143 #ifdef	__cplusplus
144 }
145 #endif
146 
147 #endif	/* _SYS_SCSI_ADAPTERS_FASCMD_H */
148