xref: /onnv-gate/usr/src/uts/sun/sys/scsi/adapters/fascmd.h (revision 6640:c92ca9b95b9c)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*6640Scth  * Common Development and Distribution License (the "License").
6*6640Scth  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*6640Scth  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*6640Scth  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate #ifndef	_SYS_SCSI_ADAPTERS_FASCMD_H
260Sstevel@tonic-gate #define	_SYS_SCSI_ADAPTERS_FASCMD_H
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #include <sys/note.h>
310Sstevel@tonic-gate #include <sys/isa_defs.h>
320Sstevel@tonic-gate #include <sys/scsi/scsi_types.h>
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #ifdef	__cplusplus
350Sstevel@tonic-gate extern "C" {
360Sstevel@tonic-gate #endif
370Sstevel@tonic-gate 
380Sstevel@tonic-gate /*
390Sstevel@tonic-gate  * The transport layer deals with things in terms of the following structure.
400Sstevel@tonic-gate  * Note	that the target	driver's view of things	is the scsi_pkt	that is
410Sstevel@tonic-gate  * enfolded as the first element of the	following structure.
420Sstevel@tonic-gate  *
430Sstevel@tonic-gate  * the preferred the cdb size is 12. fas is a scsi2 HBA driver and
440Sstevel@tonic-gate  * rarely needs 16 byte cdb's
450Sstevel@tonic-gate  */
460Sstevel@tonic-gate 
470Sstevel@tonic-gate /*
480Sstevel@tonic-gate  * preferred pkt_private length in 64-bit quantities
490Sstevel@tonic-gate  */
500Sstevel@tonic-gate #ifdef	_LP64
510Sstevel@tonic-gate #define	PKT_PRIV_SIZE	2
520Sstevel@tonic-gate #define	PKT_PRIV_LEN	16	/* in bytes */
530Sstevel@tonic-gate #else /* _ILP32 */
540Sstevel@tonic-gate #define	PKT_PRIV_SIZE	1
550Sstevel@tonic-gate #define	PKT_PRIV_LEN	8	/* in bytes */
560Sstevel@tonic-gate #endif
570Sstevel@tonic-gate 
580Sstevel@tonic-gate 
590Sstevel@tonic-gate #define	PKT2CMD(pkt)		((struct fas_cmd *)(pkt)->pkt_ha_private)
600Sstevel@tonic-gate #define	CMD2PKT(sp)		((sp)->cmd_pkt)
610Sstevel@tonic-gate 
62*6640Scth #define	EXTCMD_SIZE		(sizeof (struct fas_cmd) + scsi_pkt_size())
63*6640Scth #define	EXTCMDS_STATUS_SIZE	(sizeof (struct scsi_arq_status))
640Sstevel@tonic-gate 
650Sstevel@tonic-gate struct fas_cmd {
660Sstevel@tonic-gate 	struct scsi_pkt		*cmd_pkt;	/* the generic packet itself */
670Sstevel@tonic-gate 	struct fas_cmd		*cmd_forw;	/* ready fifo que link */
680Sstevel@tonic-gate 	uchar_t			*cmd_cdbp;	/* active command pointer */
690Sstevel@tonic-gate 
700Sstevel@tonic-gate 	uint32_t		cmd_data_count;	/* aggregate data count */
710Sstevel@tonic-gate 	uint32_t		cmd_cur_addr;	/* current dma address */
720Sstevel@tonic-gate 
730Sstevel@tonic-gate 	ushort_t		cmd_qfull_retries;
740Sstevel@tonic-gate 
750Sstevel@tonic-gate 	ushort_t		cmd_nwin;	/* number of windows */
760Sstevel@tonic-gate 	ushort_t		cmd_cur_win;	/* current window */
770Sstevel@tonic-gate 
780Sstevel@tonic-gate 	ushort_t		cmd_saved_win;	/* saved window */
790Sstevel@tonic-gate 	uint32_t		cmd_saved_data_count; /* saved aggr. count */
800Sstevel@tonic-gate 	uint32_t		cmd_saved_cur_addr; /* saved virt address */
810Sstevel@tonic-gate 	int			cmd_pkt_flags;	/* copy	of pkt_flags */
820Sstevel@tonic-gate 
830Sstevel@tonic-gate 	ddi_dma_handle_t	cmd_dmahandle;	/* dma handle */
840Sstevel@tonic-gate 	ddi_dma_cookie_t	cmd_dmacookie;	/* current dma cookie */
850Sstevel@tonic-gate 	uint32_t		cmd_dmacount;	/* total xfer count */
860Sstevel@tonic-gate 
870Sstevel@tonic-gate 	uchar_t			cmd_cdb[CDB_SIZE]; /* 12 byte cdb */
880Sstevel@tonic-gate 	uint_t			cmd_flags;	/* private flags */
890Sstevel@tonic-gate 	struct scsi_arq_status	cmd_scb;
900Sstevel@tonic-gate 	uint_t			cmd_scblen;	/* length of scb */
910Sstevel@tonic-gate 	uchar_t			cmd_slot;
920Sstevel@tonic-gate 	uchar_t			cmd_age;	/* cmd age (tagged queing) */
930Sstevel@tonic-gate 	uint_t			cmd_cdblen;	/* length of cdb */
940Sstevel@tonic-gate 	uint64_t		cmd_pkt_private[PKT_PRIV_SIZE];
950Sstevel@tonic-gate 	uint_t			cmd_privlen;	/* length of tgt private */
960Sstevel@tonic-gate 	uchar_t			cmd_tag[2];	/* command tag */
970Sstevel@tonic-gate 	uchar_t			cmd_actual_cdblen; /* length of	cdb */
980Sstevel@tonic-gate };
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per pkt", fas_cmd))
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate /*
1030Sstevel@tonic-gate  * private data	for arq	pkt
1040Sstevel@tonic-gate  */
1050Sstevel@tonic-gate struct arq_private_data	{
1060Sstevel@tonic-gate 	struct buf	*arq_save_bp;
1070Sstevel@tonic-gate 	struct fas_cmd	*arq_save_sp;
1080Sstevel@tonic-gate };
1090Sstevel@tonic-gate 
1100Sstevel@tonic-gate /*
1110Sstevel@tonic-gate  * A note about	the cmd_cdb && cmd_scb structures:
1120Sstevel@tonic-gate  *
1130Sstevel@tonic-gate  *	If the command allocation requested exceeds the	size of	CDB_SIZE,
1140Sstevel@tonic-gate  *	the cdb	will be	allocated outside this structure (via kmem_zalloc)
1150Sstevel@tonic-gate  *	The same applies to cmd_scb.
1160Sstevel@tonic-gate  */
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate /*
1190Sstevel@tonic-gate  * These are the defined flags for this	structure.
1200Sstevel@tonic-gate  */
1210Sstevel@tonic-gate #define	CFLAG_CMDDISC		0x0001	/* cmd currently disconnected */
1220Sstevel@tonic-gate #define	CFLAG_WATCH		0x0002	/* watchdog time for this command */
1230Sstevel@tonic-gate #define	CFLAG_FINISHED		0x0004	/* command completed */
1240Sstevel@tonic-gate #define	CFLAG_CHKSEG		0x0008	/* check cmd_data within seg */
1250Sstevel@tonic-gate #define	CFLAG_COMPLETED		0x0010	/* completion routine called */
1260Sstevel@tonic-gate #define	CFLAG_PREPARED		0x0020	/* pkt has been	init'ed	*/
1270Sstevel@tonic-gate #define	CFLAG_IN_TRANSPORT	0x0040	/* in use by host adapter driver */
1280Sstevel@tonic-gate #define	CFLAG_RESTORE_PTRS	0x0080	/* implicit restore ptr on reconnect */
1290Sstevel@tonic-gate #define	CFLAG_TRANFLAG		0x00ff	/* covers transport part of flags */
1300Sstevel@tonic-gate #define	CFLAG_CMDPROXY		0x000100 /* cmd	is a 'proxy' command */
1310Sstevel@tonic-gate #define	CFLAG_CMDARQ		0x000200 /* cmd	is a 'rqsense' command */
1320Sstevel@tonic-gate #define	CFLAG_DMAVALID		0x000400 /* dma	mapping	valid */
1330Sstevel@tonic-gate #define	CFLAG_DMASEND		0x000800 /* data	is going 'out' */
1340Sstevel@tonic-gate #define	CFLAG_CMDIOPB		0x001000 /* this	is an 'iopb' packet */
1350Sstevel@tonic-gate #define	CFLAG_CDBEXTERN		0x002000 /* cdb	kmem_alloc'd */
1360Sstevel@tonic-gate #define	CFLAG_SCBEXTERN		0x004000 /* scb	kmem_alloc'd */
1370Sstevel@tonic-gate #define	CFLAG_FREE		0x008000 /* packet is on	free list */
1380Sstevel@tonic-gate #define	CFLAG_PRIVEXTERN	0x020000 /* target private kmem_alloc'd	*/
1390Sstevel@tonic-gate #define	CFLAG_DMA_PARTIAL	0x040000 /* partial xfer OK */
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate #ifdef	__cplusplus
1420Sstevel@tonic-gate }
1430Sstevel@tonic-gate #endif
1440Sstevel@tonic-gate 
1450Sstevel@tonic-gate #endif	/* _SYS_SCSI_ADAPTERS_FASCMD_H */
146