File: /usr/src/linux/drivers/scsi/aic7xxx/cam.h

1     /*
2      * Data structures and definitions for the CAM system.
3      *
4      * Copyright (c) 1997 Justin T. Gibbs.
5      * Copyright (c) 2000 Adaptec Inc.
6      * All rights reserved.
7      *
8      * Redistribution and use in source and binary forms, with or without
9      * modification, are permitted provided that the following conditions
10      * are met:
11      * 1. Redistributions of source code must retain the above copyright
12      *    notice, this list of conditions, and the following disclaimer,
13      *    without modification.
14      * 2. The name of the author may not be used to endorse or promote products
15      *    derived from this software without specific prior written permission.
16      *
17      * Alternatively, this software may be distributed under the terms of the
18      * GNU Public License ("GPL").
19      *
20      * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21      * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22      * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23      * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
24      * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25      * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26      * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27      * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28      * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29      * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30      * SUCH DAMAGE.
31      *
32      * $Id: //depot/src/linux/drivers/scsi/aic7xxx/cam.h#10 $
33      */
34     
35     #ifndef _AIC7XXX_CAM_H
36     #define _AIC7XXX_CAM_H 1
37     
38     /* Provide a mapping from CAM constructs to Linux SCSI constructs */
39     
40     #define	CAM_BUS_WILDCARD ((u_int)~0)
41     #define	CAM_TARGET_WILDCARD ((u_int)~0)
42     #define	CAM_LUN_WILDCARD ((u_int)~0)
43     
44     /* CAM Status field values */
45     typedef enum {
46     	/* CCB request is in progress */
47     	CAM_REQ_INPROG		= 0x3F, /* Some value unused by Linux */
48     	/* CCB request completed without error */
49     	CAM_REQ_CMP		= DID_OK,
50     	/* CCB request aborted by the host */
51     	CAM_REQ_ABORTED		= DID_ABORT,
52     	/* Unable to abort CCB request */
53     	CAM_UA_ABORT		= DID_ERROR,
54     	/* CCB request completed with an error */
55     	CAM_REQ_CMP_ERR		= DID_ERROR,
56     	/* CAM subsytem is busy */
57     	CAM_BUSY		= DID_BUS_BUSY,
58     	/* CCB request was invalid */
59     	CAM_REQ_INVALID		= DID_BAD_TARGET,
60     	/* Supplied Path ID is invalid */
61     	CAM_PATH_INVALID	= DID_BAD_TARGET,
62     	/* Target Selection Timeout */
63     	CAM_SEL_TIMEOUT		= DID_NO_CONNECT,
64     	/* Command timeout */
65     	CAM_CMD_TIMEOUT		= DID_ERROR, /*
66     					      * Should never occur in Linux
67     					      * as the upper level code
68     					      * handles all timeout processing.
69     					      */
70     	/* SCSI error, look at error code in CCB */
71     	CAM_SCSI_STATUS_ERROR	= DID_OK, /* Linux looks at status byte */
72     	/* SCSI Bus Reset Sent/Received */
73     	CAM_SCSI_BUS_RESET	= DID_RESET,
74     	/* Uncorrectable parity error occurred */
75     	CAM_UNCOR_PARITY	= DID_PARITY,
76     	/* Autosense: request sense cmd fail */
77     	CAM_AUTOSENSE_FAIL	= DID_ERROR,
78     	/* No HBA Detected Error */
79     	CAM_NO_HBA		= DID_ERROR,
80     	/* Data Overrun error */
81     	CAM_DATA_RUN_ERR	= DID_ERROR,
82     	/* Unexpected Bus Free */
83     	CAM_UNEXP_BUSFREE	= DID_ERROR,
84     	/* CCB length supplied is inadequate */
85     	CAM_CCB_LEN_ERR		= DID_ERROR,
86     	/* Unable to provide requested capability */
87     	CAM_PROVIDE_FAIL	= DID_ERROR,
88     	/* A SCSI BDR msg was sent to target */
89     	CAM_BDR_SENT		= DID_RESET,
90     	/* CCB request terminated by the host */
91     	CAM_REQ_TERMIO		= DID_ERROR,
92     	/* Unrecoverable Host Bus Adapter Error */
93     	CAM_UNREC_HBA_ERROR	= DID_ERROR,
94     	/* The request was too large for this host */
95     	CAM_REQ_TOO_BIG		= DID_ERROR,
96     	/*
97     	 * This request should be requeued to preserve
98     	 * transaction ordering.  This typically occurs
99     	 * when the SIM recognizes an error that should
100     	 * freeze the queue and must place additional
101     	 * requests for the target at the sim level
102     	 * back into the XPT queue.
103     	 */
104     	CAM_REQUEUE_REQ		= DID_BUS_BUSY,
105     
106     	CAM_STATUS_MASK		= 0x3F
107     } cam_status;
108     
109     #if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
110     #define	SCSI_DATA_READ	1
111     #define	SCSI_DATA_WRITE 2
112     #define SCSI_DATA_NONE  3
113     #endif
114     
115     /*
116      * Definitions for the asynchronous callback CCB fields.
117      */
118     typedef enum {
119     	AC_GETDEV_CHANGED	= 0x800,/* Getdev info might have changed */
120     	AC_INQ_CHANGED		= 0x400,/* Inquiry info might have changed */
121     	AC_TRANSFER_NEG		= 0x200,/* New transfer settings in effect */
122     	AC_LOST_DEVICE		= 0x100,/* A device went away */
123     	AC_FOUND_DEVICE		= 0x080,/* A new device was found */
124     	AC_PATH_DEREGISTERED	= 0x040,/* A path has de-registered */
125     	AC_PATH_REGISTERED	= 0x020,/* A new path has been registered */
126     	AC_SENT_BDR		= 0x010,/* A BDR message was sent to target */
127     	AC_SCSI_AEN		= 0x008,/* A SCSI AEN has been received */
128     	AC_UNSOL_RESEL		= 0x002,/* Unsolicited reselection occurred */
129     	AC_BUS_RESET		= 0x001 /* A SCSI bus reset occurred */
130     } ac_code;
131     
132     typedef enum {
133     	CAM_DIR_IN		= SCSI_DATA_READ,
134     	CAM_DIR_OUT		= SCSI_DATA_WRITE,
135     	CAM_DIR_NONE		= SCSI_DATA_NONE
136     } ccb_flags;
137     
138     #endif /* _AIC7XXX_CAM_H */
139