xref: /openbsd/sys/dev/ic/aic7xxx_cam.h (revision 17df1aa7)
1 /*	$OpenBSD: aic7xxx_cam.h,v 1.6 2005/12/10 02:45:20 krw Exp $	*/
2 /*	$NetBSD: aic7xxx_cam.h,v 1.3 2003/04/20 11:17:20 fvdl Exp $	*/
3 
4 /*
5  * Data structures and definitions for the CAM system.
6  *
7  * Copyright (c) 1997 Justin T. Gibbs.
8  * Copyright (c) 2000 Adaptec Inc.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. The name of the author may not be used to endorse or promote products
18  *    derived from this software without specific prior written permission.
19  *
20  * Alternatively, this software may be distributed under the terms of the
21  * GNU General Public License ("GPL").
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
27  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  */
36 /*
37  * Ported from FreeBSD by Pascal Renauld, Network Storage Solutions, Inc. - April 2003
38  */
39 
40 #ifndef _AIC7XXX_CAM_H
41 #define _AIC7XXX_CAM_H
42 
43 #define SCSI_REV_2	2
44 
45 #define	CAM_BUS_WILDCARD ((u_int)~0)
46 #define	CAM_TARGET_WILDCARD ((u_int)~0)
47 #define	CAM_LUN_WILDCARD -1
48 
49 /*
50  * Translate FreeBSD names for SCSI status byte values to OpenBSD names.
51  */
52 #define SCSI_STATUS_OK                  SCSI_OK
53 #define SCSI_STATUS_CHECK_COND          SCSI_CHECK
54 #define SCSI_STATUS_COND_MET            SCSI_COND_MET
55 #define SCSI_STATUS_BUSY                SCSI_BUSY
56 #define SCSI_STATUS_INTERMED            SCSI_INTERM
57 #define SCSI_STATUS_INTERMED_COND_MET   SCSI_INTERMED_COND_MET
58 #define SCSI_STATUS_RESERV_CONFLICT     SCSI_RESERV_CONFLICT
59 #define SCSI_STATUS_CMD_TERMINATED      SCSI_TERMINATED
60 #define SCSI_STATUS_QUEUE_FULL          SCSI_QUEUE_FULL
61 
62 #define XS_CTL_DATA_IN		SCSI_DATA_IN
63 #define XS_CTL_POLL		SCSI_POLL
64 #define XS_CTL_RESET		SCSI_RESET
65 
66 #define MSG_EXT_PPR_QAS_REQ	MSG_EXT_PPR_PROT_QAS
67 #define MSG_EXT_PPR_IU_REQ	MSG_EXT_PPR_PROT_IUS
68 #define MSG_EXT_PPR_DT_REQ	MSG_EXT_PPR_PROT_DT
69 #define MSG_ORDERED_TASK	MSG_ORDERED_Q_TAG
70 #define MSG_SIMPLE_TASK		MSG_SIMPLE_Q_TAG
71 #define MSG_ABORT_TASK		MSG_ABORT_TAG
72 
73 #define scsipi_channel		scsi_link
74 #define scsipi_xfer		scsi_xfer
75 #define scsipi_adapter		scsi_adapter
76 #define scsipi_sense_data	scsi_sense_data
77 #define scsipi_sense		scsi_sense
78 #define scsipi_periph		scsi_link
79 
80 #define	callout_reset(timer, timeout, func, arg) do {	\
81 	if (!timeout_initialized((timer)))		\
82 		timeout_set((timer), (func), (arg));	\
83 	timeout_add((timer), (timeout));		\
84 } while (0)
85 
86 #define aic_delay	DELAY
87 
88 #define aic_htobe16(x) htobe16(x)
89 #define aic_htobe32(x) htobe32(x)
90 #define aic_htobe64(x) htobe64(x)
91 #define aic_htole16(x) htole16(x)
92 #define aic_htole32(x) htole32(x)
93 #define aic_htole64(x) htole64(x)
94 
95 #define aic_be16toh(x) be16toh(x)
96 #define aic_be32toh(x) be32toh(x)
97 #define aic_be64toh(x) be64toh(x)
98 #define aic_le16toh(x) letoh16(x)
99 #define aic_le32toh(x) letoh32(x)
100 #define aic_le64toh(x) letoh64(x)
101 
102 #define xs_control	flags
103 #define xs_callout	stimeout
104 #define xs_status	status
105 
106 /* CAM Status field values */
107 typedef enum {
108 	CAM_REQ_INPROG,		/* CCB request is in progress */
109 	CAM_REQ_CMP,		/* CCB request completed without error */
110 	CAM_REQ_ABORTED,	/* CCB request aborted by the host */
111 	CAM_UA_ABORT,		/* Unable to abort CCB request */
112 	CAM_REQ_CMP_ERR,	/* CCB request completed with an error */
113 	CAM_BUSY,		/* CAM subsytem is busy */
114 	CAM_REQ_INVALID,	/* CCB request was invalid */
115 	CAM_PATH_INVALID,	/* Supplied Path ID is invalid */
116 	CAM_SEL_TIMEOUT,	/* Target Selection Timeout */
117 	CAM_CMD_TIMEOUT,	/* Command timeout */
118 	CAM_SCSI_STATUS_ERROR,	/* SCSI error, look at error code in CCB */
119 	CAM_SCSI_BUS_RESET,	/* SCSI Bus Reset Sent/Received */
120 	CAM_UNCOR_PARITY,	/* Uncorrectable parity error occurred */
121 	CAM_AUTOSENSE_FAIL,	/* Autosense: request sense cmd fail */
122 	CAM_NO_HBA,		/* No HBA Detected Error */
123 	CAM_DATA_RUN_ERR,	/* Data Overrun error */
124 	CAM_UNEXP_BUSFREE,	/* Unexpected Bus Free */
125 	CAM_SEQUENCE_FAIL,	/* Protocol Violation */
126 	CAM_CCB_LEN_ERR,	/* CCB length supplied is inadequate */
127 	CAM_PROVIDE_FAIL,	/* Unable to provide requested capability */
128 	CAM_BDR_SENT,		/* A SCSI BDR msg was sent to target */
129 	CAM_REQ_TERMIO,		/* CCB request terminated by the host */
130 	CAM_UNREC_HBA_ERROR,	/* Unrecoverable Host Bus Adapter Error */
131 	CAM_REQ_TOO_BIG,	/* The request was too large for this host */
132 	CAM_UA_TERMIO,		/* Unable to terminate I/O CCB request */
133 	CAM_MSG_REJECT_REC,	/* Message Reject Received */
134 	CAM_DEV_NOT_THERE,	/* SCSI Device Not Installed/there */
135 	CAM_RESRC_UNAVAIL,	/* Resource Unavailable */
136 	/*
137 	 * This request should be requeued to preserve
138 	 * transaction ordering.  This typically occurs
139 	 * when the SIM recognizes an error that should
140 	 * freeze the queue and must place additional
141 	 * requests for the target at the sim level
142 	 * back into the XPT queue.
143 	 */
144 	CAM_REQUEUE_REQ,
145 	CAM_DEV_QFRZN		= 0x40,
146 
147 	CAM_STATUS_MASK		= 0x3F
148 } cam_status;
149 
150 typedef enum {
151   	CAM_DIR_IN		= SCSI_DATA_IN,
152 	CAM_DIR_OUT		= SCSI_DATA_OUT
153 } ccb_flags;
154 
155 typedef enum {
156 	AC_BUS_RESET            =       0x001,
157 	AC_UNSOL_RESEL          =       0x002,
158 	AC_SCSI_AEN             =       0x008,
159 	AC_SENT_BDR             =       0x010,
160 	AC_PATH_REGISTERED      =       0x020,
161 	AC_PATH_DEREGISTERED    =       0x040,
162 	AC_FOUND_DEVICE         =       0x080,
163 	AC_LOST_DEVICE          =       0x100,
164 	AC_TRANSFER_NEG         =       0x200,
165 	AC_INQ_CHANGED          =       0x400,
166 	AC_GETDEV_CHANGED       =       0x800
167 } ac_code;
168 
169 #endif /* _AIC7XXX_CAM_H */
170