1 /*	$OpenBSD: aic7xxx_cam.h,v 1.1 2003/12/24 22:45:45 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 
46 #define	CAM_BUS_WILDCARD ((u_int)~0)
47 #define	CAM_TARGET_WILDCARD ((u_int)~0)
48 #define	CAM_LUN_WILDCARD -1
49 
50 /*
51  * XXX translate FreeBSD SCSI status byte values to NetBSD, and define
52  * a few more.
53  */
54 #define SCSI_STATUS_OK                  SCSI_OK
55 #define SCSI_STATUS_CHECK_COND          SCSI_CHECK
56 #define SCSI_STATUS_COND_MET            SCSI_COND_MET
57 #define SCSI_STATUS_BUSY                SCSI_BUSY
58 #define SCSI_STATUS_INTERMED            SCSI_INTERM
59 #define SCSI_STATUS_INTERMED_COND_MET   SCSI_INTERMED_COND_MET
60 #define SCSI_STATUS_RESERV_CONFLICT     SCSI_RESERV_CONFLICT
61 #define SCSI_STATUS_CMD_TERMINATED      SCSI_TERMINATED
62 #define SCSI_STATUS_QUEUE_FULL          SCSI_QUEUE_FULL
63 
64 #define XS_STS_DONE		ITSDONE
65 #define XS_CTL_DATA_IN		SCSI_DATA_IN
66 #define XS_CTL_DATA_OUT		SCSI_DATA_OUT
67 #define XS_CTL_POLL		SCSI_POLL
68 #define XS_CTL_SILENT		SCSI_SILENT
69 #define XS_CTL_NOSLEEP		SCSI_NOSLEEP
70 #define XS_CTL_RESET		SCSI_RESET
71 
72 #define MSG_EXT_PPR_DT_REQ	MSG_EXT_PPR_PROT_DT
73 #define MSG_ORDERED_TASK	MSG_ORDERED_Q_TAG
74 #define MSG_SIMPLE_TASK		MSG_SIMPLE_Q_TAG
75 #define MSG_ABORT_TASK		MSG_ABORT_TAG
76 
77 #define scsipi_channel		scsi_link
78 #define scsipi_xfer		scsi_xfer
79 #define scsipi_adapter		scsi_adapter
80 #define scsipi_sense_data	scsi_sense_data
81 #define scsipi_sense		scsi_sense
82 #define scsipi_periph		scsi_link
83 #define	scsipi_adapter_req_t	int
84 
85 #define scsipi_periph_freeze(a, b)
86 #define scsipi_periph_thaw(a, b)
87 #define scsipi_channel_freeze(a, b)
88 #define scsipi_channel_thaw(a, b)
89 #define	scsipi_printaddr(sc_link)	sc_print_addr(sc_link)
90 #define scsipi_done(xs)			scsi_done(xs)
91 
92 #define	callout_reset(timer, timeout, func, arg) timeout_add(timer, (timeout))
93 
94 #define xs_control	flags
95 #define xs_callout	stimeout
96 #define xs_status	status
97 #define xs_periph	sc_link
98 
99 #define periph_target	target
100 #define periph_lun	lun
101 
102 #define chan_ntargets	adapter_buswidth
103 #define chan_nluns	luns
104 #define chan_id		adapter_target
105 
106 #define	adapt_request	scsi_cmd
107 #define adapt_minphys	scsi_minphys
108 #define adapt_ioctl	ioctl
109 #define adapt_openings	openings
110 
111 /* CAM Status field values */
112 typedef enum {
113 	CAM_REQ_INPROG,		/* CCB request is in progress */
114 	CAM_REQ_CMP,		/* CCB request completed without error */
115 	CAM_REQ_ABORTED,	/* CCB request aborted by the host */
116 	CAM_UA_ABORT,		/* Unable to abort CCB request */
117 	CAM_REQ_CMP_ERR,	/* CCB request completed with an error */
118 	CAM_BUSY,		/* CAM subsytem is busy */
119 	CAM_REQ_INVALID,	/* CCB request was invalid */
120 	CAM_PATH_INVALID,	/* Supplied Path ID is invalid */
121 	CAM_SEL_TIMEOUT,	/* Target Selection Timeout */
122 	CAM_CMD_TIMEOUT,	/* Command timeout */
123 	CAM_SCSI_STATUS_ERROR,	/* SCSI error, look at error code in CCB */
124 	CAM_SCSI_BUS_RESET,	/* SCSI Bus Reset Sent/Received */
125 	CAM_UNCOR_PARITY,	/* Uncorrectable parity error occurred */
126 	CAM_AUTOSENSE_FAIL,	/* Autosense: request sense cmd fail */
127 	CAM_NO_HBA,		/* No HBA Detected Error */
128 	CAM_DATA_RUN_ERR,	/* Data Overrun error */
129 	CAM_UNEXP_BUSFREE,	/* Unexpected Bus Free */
130 	CAM_SEQUENCE_FAIL,	/* Protocol Violation */
131 	CAM_CCB_LEN_ERR,	/* CCB length supplied is inadequate */
132 	CAM_PROVIDE_FAIL,	/* Unable to provide requested capability */
133 	CAM_BDR_SENT,		/* A SCSI BDR msg was sent to target */
134 	CAM_REQ_TERMIO,		/* CCB request terminated by the host */
135 	CAM_UNREC_HBA_ERROR,	/* Unrecoverable Host Bus Adapter Error */
136 	CAM_REQ_TOO_BIG,	/* The request was too large for this host */
137 	CAM_UA_TERMIO,		/* Unable to terminate I/O CCB request */
138 	CAM_MSG_REJECT_REC,	/* Message Reject Received */
139 	CAM_DEV_NOT_THERE,	/* SCSI Device Not Installed/there */
140 	CAM_RESRC_UNAVAIL,	/* Resource Unavailable */
141 	/*
142 	 * This request should be requeued to preserve
143 	 * transaction ordering.  This typically occurs
144 	 * when the SIM recognizes an error that should
145 	 * freeze the queue and must place additional
146 	 * requests for the target at the sim level
147 	 * back into the XPT queue.
148 	 */
149 	CAM_REQUEUE_REQ,
150 	CAM_DEV_QFRZN		= 0x40,
151 
152 	CAM_STATUS_MASK		= 0x3F
153 } cam_status;
154 
155 typedef enum {
156   	CAM_DIR_IN		= XS_CTL_DATA_IN,
157 	CAM_DIR_OUT		= XS_CTL_DATA_OUT,
158 } ccb_flags;
159 
160 typedef enum {
161 	AC_BUS_RESET            =       0x001,
162 	AC_UNSOL_RESEL          =       0x002,
163 	AC_SCSI_AEN             =       0x008,
164 	AC_SENT_BDR             =       0x010,
165 	AC_PATH_REGISTERED      =       0x020,
166 	AC_PATH_DEREGISTERED    =       0x040,
167 	AC_FOUND_DEVICE         =       0x080,
168 	AC_LOST_DEVICE          =       0x100,
169 	AC_TRANSFER_NEG         =       0x200,
170 	AC_INQ_CHANGED          =       0x400,
171 	AC_GETDEV_CHANGED       =       0x800,
172 } ac_code;
173 
174 #endif /* _AIC7XXX_CAM_H */
175