xref: /titanic_52/usr/src/uts/common/sys/stmf_defines.h (revision 716c180559045549271833327182dc6a266134f1)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 #ifndef	_STMF_DEFINES_H
25 #define	_STMF_DEFINES_H
26 
27 #ifdef	__cplusplus
28 extern "C" {
29 #endif
30 
31 #define	BIT_0	0x1
32 #define	BIT_1	0x2
33 #define	BIT_2	0x4
34 #define	BIT_3	0x8
35 #define	BIT_4	0x10
36 #define	BIT_5	0x20
37 #define	BIT_6	0x40
38 #define	BIT_7	0x80
39 #define	BIT_8	0x100
40 #define	BIT_9	0x200
41 #define	BIT_10	0x400
42 #define	BIT_11	0x800
43 #define	BIT_12	0x1000
44 #define	BIT_13	0x2000
45 #define	BIT_14	0x4000
46 #define	BIT_15	0x8000
47 #define	BIT_16	0x10000
48 #define	BIT_17	0x20000
49 #define	BIT_18	0x40000
50 #define	BIT_19	0x80000
51 #define	BIT_20	0x100000
52 #define	BIT_21	0x200000
53 #define	BIT_22	0x400000
54 #define	BIT_23	0x800000
55 #define	BIT_24	0x1000000
56 #define	BIT_25	0x2000000
57 #define	BIT_26	0x4000000
58 #define	BIT_27	0x8000000
59 #define	BIT_28	0x10000000
60 #define	BIT_29	0x20000000
61 #define	BIT_30	0x40000000
62 #define	BIT_31	0x80000000
63 
64 /*
65  * stmf status definitions
66  */
67 typedef	uint64_t		stmf_status_t;
68 #define	STMF_SUCCESS		((uint64_t)0)
69 #define	STMF_FAILURE		((uint64_t)0x1000000000000000)
70 #define	STMF_TARGET_FAILURE	((uint64_t)0x2000000000000000)
71 #define	STMF_LU_FAILURE		((uint64_t)0x3000000000000000)
72 #define	STMF_FSC(x)		(((uint64_t)(x)) << 32)
73 #define	STMF_GET_FSC(x)		((((uint64_t)(x)) >> 32) & 0xFFFFFF)
74 #define	STMF_RETRY_BIT		((uint64_t)0x0080000000000000)
75 #define	STMF_BUSY		(STMF_FAILURE | STMF_RETRY_BIT | STMF_FSC(0))
76 #define	STMF_NOT_FOUND		(STMF_FAILURE | STMF_FSC(1))
77 #define	STMF_INVALID_ARG	(STMF_FAILURE | STMF_FSC(2))
78 #define	STMF_LUN_TAKEN		(STMF_FAILURE | STMF_FSC(3))
79 #define	STMF_ABORTED		(STMF_FAILURE | STMF_FSC(5))
80 #define	STMF_ABORT_SUCCESS	(STMF_FAILURE | STMF_FSC(6))
81 #define	STMF_ALLOC_FAILURE	(STMF_FAILURE | STMF_FSC(7))
82 #define	STMF_ALREADY		(STMF_FAILURE | STMF_FSC(8))
83 #define	STMF_TIMEOUT		(STMF_FAILURE | STMF_FSC(9))
84 #define	STMF_NOT_SUPPORTED	(STMF_FAILURE | STMF_FSC(10))
85 #define	STMF_BADSTATE		(STMF_FAILURE | STMF_FSC(11))
86 
87 #define	GET_BYTE_OFFSET(ptr, off)	(((uint8_t *)(ptr)) + (off))
88 #define	GET_STRUCT_SIZE(s)		((sizeof (s) + 7) & 0xfffffff8)
89 #define	READ_SCSI16(addr, type)		((((type)(((uint8_t *)(addr))[0])) \
90 								<< 8) |\
91 					((type)(((uint8_t *)(addr))[1])))
92 #define	READ_SCSI21(addr, type)		((((type)(((uint8_t *)(addr))[0] & \
93 								0x1F)) << 16)\
94 					    | (READ_SCSI16(addr+1, type)))
95 #define	READ_SCSI32(addr, type)		(((READ_SCSI16(addr, type)) << 16) |\
96 					    (READ_SCSI16((addr+2), type)))
97 #define	READ_SCSI64(addr, type)		(((READ_SCSI32(addr, type)) << 32) |\
98 					    (READ_SCSI32((addr+4), type)))
99 #define	PTR2INT(p, t)	((t)((ulong_t)(p)))
100 #define	INT2PTR(i, t)	((t)((ulong_t)(i)))
101 
102 /*
103  * CDB definitions that don't exist in commands.h
104  */
105 #define	SCMD_SYNCHRONIZE_CACHE_G4		0x91
106 
107 /*
108  * Common key, asc, ascq for stmf_scsilib_send_status
109  */
110 #define	STMF_SAA_MEDIUM_NOT_PRESENT		0X023A00
111 #define	STMF_SAA_LU_NO_ACCESS_TRANSITION	0X02040A
112 #define	STMF_SAA_LU_NO_ACCESS_STANDBY		0X02040B
113 #define	STMF_SAA_LU_NO_ACCESS_UNAVAIL		0X02040C
114 #define	STMF_SAA_WRITE_ERROR			0x030C00
115 #define	STMF_SAA_READ_ERROR			0x031100
116 #define	STMF_SAA_OPERATION_IN_PROGRESS		0x050016
117 #define	STMF_SAA_INVALID_FIELD_IN_CMD_IU	0x050E03
118 #define	STMF_SAA_PARAM_LIST_LENGTH_ERROR	0x051A00
119 #define	STMF_SAA_INVALID_OPCODE			0x052000
120 #define	STMF_SAA_INVALID_LU			0x052009
121 #define	STMF_SAA_LBA_OUT_OF_RANGE		0x052100
122 #define	STMF_SAA_INVALID_FIELD_IN_CDB		0x052400
123 #define	STMF_SAA_INVALID_FIELD_IN_PARAM_LIST	0x052600
124 #define	STMF_SAA_INVALID_RELEASE_OF_PR		0x052604
125 #define	STMF_SAA_MEDIUM_REMOVAL_PREVENTED	0x055302
126 #define	STMF_SAA_INSUFFICIENT_REG_RESOURCES	0x055504
127 #define	STMF_SAA_POR				0x062900
128 #define	STMF_SAA_MODE_PARAMETERS_CHANGED	0x062A01
129 #define	STMF_SAA_ASYMMETRIC_ACCESS_CHANGED	0x062A06
130 #define	STMF_SAA_CAPACITY_DATA_HAS_CHANGED	0x062A09
131 #define	STMF_SAA_REPORT_LUN_DATA_HAS_CHANGED	0x063F0E
132 #define	STMF_SAA_WRITE_PROTECTED		0X072700
133 
134 struct stmf_lu_provider;
135 struct stmf_lu;
136 struct stmf_port_provider;
137 struct stmf_local_port;
138 struct stmf_remote_port;
139 struct stmf_scsi_session;
140 struct scsi_task;
141 struct scsi_devid_desc;
142 struct scsi_transport_id;
143 struct stmf_data_buf;
144 struct stmf_lun_map;
145 struct scsi_devid_desc;
146 
147 #ifdef	__cplusplus
148 }
149 #endif
150 
151 #endif	/* _STMF_DEFINES_H */
152