xref: /titanic_41/usr/src/uts/common/sys/sbp2/defs.h (revision cde2885fdf538266ee2a3b08dee2d5075ce8fa2b)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_SBP2_DEFS_H
28 #define	_SYS_SBP2_DEFS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * Serial Bus Protocol 2 (SBP-2) definitions
34  *
35  * References are to ANSI NCITS 325-1998 unless specified otherwise
36  */
37 
38 #include <sys/sbp2/common.h>
39 #include <sys/note.h>
40 
41 #ifdef	__cplusplus
42 extern "C" {
43 #endif
44 
45 /*
46  * Operation request blocks (ORB's)
47  * Note that the targets specify the minimum ORB size (ref: 7.8.4)
48  *
49  * dummy ORB (ref: 5.1.1)
50  */
51 typedef struct sbp2_dummy_orb {
52 	sbp2_orbp_t	do_next_orb;	/* next ORB pointer */
53 	uint32_t	do_ignored1[2];	/* ignored */
54 	uint16_t	do_params;	/* parameters */
55 	uint16_t	do_ignored2;	/* ignored */
56 } sbp2_dummy_orb_t;
57 
58 /* parameters */
59 #define	SBP2_ORB_NOTIFY			0x8000	/* notify bit */
60 #define	SBP2_ORB_RQ_FMT			0x6000	/* ORB format */
61 
62 /* ORB formats */
63 #define	SBP2_ORB_RQ_FMT_SBP2		0x0000	/* SBP2 ORB */
64 #define	SBP2_ORB_RQ_FMT_DUMMY		0x6000	/* dummy (NOP) ORB */
65 
66 /* command block ORB (ref: 5.1.2) */
67 typedef struct sbp2_cmd_orb {
68 	sbp2_orbp_t	co_next_orb;	/* next ORB pointer */
69 	uint32_t	co_data_descr[2]; /* data descriptor */
70 	uint16_t	co_params;	/* parameters */
71 	uint16_t	co_data_size;	/* data size */
72 } sbp2_cmd_orb_t;
73 
74 /* request */
75 #define	SBP2_ORB_CMD_DIR		0x0800
76 #define	SBP2_ORB_CMD_SPD		0x0700
77 #define	SBP2_ORB_CMD_SPD_SHIFT		8
78 #define	SBP2_ORB_CMD_MAX_PAYLOAD 	0x00F0
79 #define	SBP2_ORB_CMD_MAX_PAYLOAD_SHIFT 	4
80 #define	SBP2_ORB_CMD_PT			0x0008
81 #define	SBP2_ORB_CMD_PSZ		0x0007
82 
83 /* speeds */
84 #define	SBP2_ORB_CMD_SPD_S100		0x0000
85 #define	SBP2_ORB_CMD_SPD_S200		0x0100
86 #define	SBP2_ORB_CMD_SPD_S400		0x0200
87 #define	SBP2_ORB_CMD_SPD_S800		0x0300
88 #define	SBP2_ORB_CMD_SPD_S1600		0x0400
89 #define	SBP2_ORB_CMD_SPD_S3200		0x0500
90 
91 /* management ORB (ref: 5.1.3) */
92 typedef struct sbp2_mgt_orb {
93 	uint32_t	mo_fdep1[4];	/* function-dependent */
94 	uint16_t	mo_params;	/* parameters */
95 	uint16_t	mo_fdep2;	/* function-dependent */
96 	uint32_t	mo_fdep3;	/* function-dependent */
97 	sbp2_addr_t	mo_status_fifo;	/* status FIFO address */
98 } sbp2_mgt_orb_t;
99 
100 /* parameters */
101 #define	SBP2_ORB_MGT_FUNC 		0x000F	/* mgt function */
102 
103 /* mgt functions */
104 #define	SBP2_ORB_MGT_FUNC_LOGIN 	0x0000
105 #define	SBP2_ORB_MGT_FUNC_QUERY_LOGINS	0x0001
106 #define	SBP2_ORB_MGT_FUNC_RECONNECT 	0x0003
107 #define	SBP2_ORB_MGT_FUNC_SET_PASSWORD	0x0004
108 #define	SBP2_ORB_MGT_FUNC_LOGOUT 	0x0007
109 #define	SBP2_ORB_MGT_FUNC_ABORT_TASK 	0x000B
110 #define	SBP2_ORB_MGT_FUNC_ABORT_TASK_SET 0x000C
111 #define	SBP2_ORB_MGT_FUNC_LUN_RESET 	0x000E
112 #define	SBP2_ORB_MGT_FUNC_TARGET_RESET	0x000F
113 
114 /* login ORB (ref: 5.1.3.1) */
115 typedef struct sbp2_login_orb {
116 	sbp2_addr_t	lo_passwd;	/* password */
117 	sbp2_addr_t	lo_resp;	/* response */
118 	uint16_t	lo_params;	/* parameters */
119 	uint16_t	lo_lun;		/* lun */
120 	uint16_t	lo_passwd_len;	/* password length */
121 	uint16_t	lo_resp_len;	/* response length */
122 	sbp2_addr_t	lo_status_fifo;	/* status FIFO address */
123 } sbp2_login_orb_t;
124 
125 /* parameters */
126 #define	SBP2_ORB_LOGIN_EXCL		0x1000
127 #define	SBP2_ORB_LOGIN_RECONNECT	0x00F0
128 #define	SBP2_ORB_LOGIN_RECONNECT_SHIFT	4
129 
130 /* login response */
131 typedef struct sbp2_login_resp {
132 	uint16_t	lr_len;		/* login length */
133 	uint16_t	lr_login_id;	/* login ID */
134 	sbp2_addr_t	lr_cmd_agent;	/* command block agent address */
135 	uint16_t	lr_reserved;	/* reserved */
136 	uint16_t	lr_reconnect_hold; /* reconnect hold */
137 } sbp2_login_resp_t;
138 
139 /* query logins ORB (ref: 5.1.3.2) */
140 typedef struct sbp2_qlogins_orb {
141 	uint32_t	qo_reserved1[2]; /* reserved */
142 	sbp2_addr_t	qo_resp;	/* query response address */
143 	uint16_t	qo_params;	/* parameters */
144 	uint16_t	qo_lun;		/* LUN */
145 	uint16_t	qo_reserved2;	/* reserved */
146 	uint16_t	qo_len;		/* lengths */
147 	sbp2_addr_t	qo_status_fifo; /* status FIFO address */
148 } sbp2_qlogins_orb_t;
149 
150 /* reconnect ORB (ref: 5.1.3.3) */
151 typedef struct sbp2_reconnect_orb {
152 	uint32_t	ro_reserved1[4]; /* reserved */
153 	uint16_t	ro_params;	/* parameters */
154 	uint16_t	ro_login_id;	/* login ID */
155 	uint32_t	ro_reserved2;	/* reserved */
156 	sbp2_addr_t	ro_status_fifo; /* status FIFO address */
157 } sbp2_reconnect_orb_t;
158 
159 /* logout ORB (ref: 5.1.3.4) */
160 typedef struct sbp2_logout_orb {
161 	uint32_t	lo_reserved1[4]; /* reserved */
162 	uint16_t	lo_params;	/* parameters */
163 	uint16_t	lo_login_id;	/* login ID */
164 	uint32_t	lo_reserved2;	/* reserved */
165 	sbp2_addr_t	lo_status_fifo; /* status FIFO address */
166 } sbp2_logout_orb_t;
167 
168 /* task management ORB (ref: 5.1.3.5) */
169 typedef struct sbp2_task_mgt_orb {
170 	sbp2_orbp_t	to_orb;		/* task pointer */
171 	uint32_t	to_reserved1[2]; /* reserved */
172 	uint16_t	to_params;	/* parameters */
173 	uint16_t	to_login_id;	/* login ID */
174 	uint32_t	to_reserved;	/* reserved */
175 	sbp2_addr_t	to_status_fifo; /* status FIFO address */
176 } sbp2_task_mgt_orb_t;
177 
178 /* status block (ref: 5.3) */
179 typedef struct sbp2_status {
180 	uint8_t		st_param;	/* parameters */
181 	uint8_t		st_sbp_status;	/* SBP status */
182 	uint16_t	st_orb_offset_hi; /* ORB offset hi */
183 	uint32_t	st_orb_offset_lo; /* ORB offset lo */
184 	uint32_t	st_data[6];	/* command set-dependent data */
185 } sbp2_status_t;
186 
187 /* parameters */
188 #define	SBP2_ST_SRC		0xC0
189 #define	SBP2_ST_SRC_SHIFT	6
190 #define	SBP2_ST_RESP		0x30
191 #define	SBP2_ST_RESP_SHIFT	4
192 #define	SBP2_ST_DEAD		0x08
193 #define	SBP2_ST_LEN		0x07
194 
195 /* status origins */
196 #define	SBP2_ST_SRC_ORB		0x00
197 #define	SBP2_ST_SRC_ORB_NULL	0x40
198 #define	SBP2_ST_SRC_UNSOLICITED	0x80
199 
200 /* response status */
201 #define	SBP2_ST_RESP_COMPLETE	0x00	/* REQUEST COMPLETE */
202 #define	SBP2_ST_RESP_TRANFAIL	0x10	/* TRANSPORT FAILURE */
203 #define	SBP2_ST_RESP_ILLREQ	0x20	/* ILLEGAL REQUEST */
204 #define	SBP2_ST_RESP_VENDOR	0x30	/* VENDOR DEPENDENT */
205 
206 /* SBP status, when response status is REQUEST COMPLETE */
207 #define	SBP2_ST_SBP_NOINFO	0x00	/* no additional info */
208 #define	SBP2_ST_SBP_REQ_TYPE	0x01	/* req type not supported */
209 #define	SBP2_ST_SBP_SPD		0x02	/* speed not supported */
210 #define	SBP2_ST_SBP_PSZ		0x03	/* page size not supported */
211 #define	SBP2_ST_SBP_ACCESS	0x04	/* access denied */
212 #define	SBP2_ST_SBP_LUN		0x05	/* LUN not supported */
213 #define	SBP2_ST_SBP_PAYLOAD	0x06	/* max payload too small */
214 #define	SBP2_ST_SBP_RSRC	0x08	/* resources unavailable */
215 #define	SBP2_ST_SBP_FUNC	0x09	/* function rejected */
216 #define	SBP2_ST_SBP_LOGIN_ID	0x0A	/* login ID not recognized */
217 #define	SBP2_ST_SBP_DUMMY_ORB	0x0B	/* dummy ORB completed */
218 #define	SBP2_ST_SBP_REQ_ABORT	0x0C	/* request aborted */
219 #define	SBP2_ST_SBP_UNSPEC	0xFF	/* unspecified error */
220 
221 /* SBP status, when response status is TRANSPORT FAILURE */
222 #define	SBP2_ST_SBP_OBJ		0xC0	/* failed object */
223 #define	SBP2_ST_SBP_ERR		0x0F	/* serial bus error */
224 
225 /* objects */
226 #define	SBP2_ST_SBP_OBJ_ORB	0x00	/* ORB */
227 #define	SBP2_ST_SBP_OBJ_DATA	0x40	/* data buffer */
228 #define	SBP2_ST_SBP_OBJ_PT	0x80	/* page table */
229 #define	SBP2_ST_SBP_OBJ_UNSPEC	0xC0	/* unable to specify */
230 
231 /* serial bus errors */
232 #define	SBP2_ST_SBP_ERR_ACK		0x00	/* missing ackknowledge */
233 #define	SBP2_ST_SBP_ERR_TIMEOUT		0x02	/* time-out error */
234 #define	SBP2_ST_SBP_ERR_ACK_BUSY_X	0x04	/* ack_busy_X */
235 #define	SBP2_ST_SBP_ERR_ACK_BUSY_A	0x05	/* ack_busy_A */
236 #define	SBP2_ST_SBP_ERR_ACK_BUSY_B	0x06	/* ack_busy_B */
237 #define	SBP2_ST_SBP_ERR_TARDY		0x0B	/* tardy limit exceeded */
238 #define	SBP2_ST_SBP_ERR_CONFLICT	0x0C	/* conflict error */
239 #define	SBP2_ST_SBP_ERR_DATA		0x0D	/* data error */
240 #define	SBP2_ST_SBP_ERR_TYPE		0x0E	/* type error */
241 #define	SBP2_ST_SBP_ERR_ADDR		0x0F	/* address error */
242 
243 
244 /* command block agent registers (ref: 6.4) */
245 #define	SBP2_AGENT_STATE_OFFSET		0x00
246 #define	SBP2_AGENT_RESET_OFFSET		0x04
247 #define	SBP2_ORB_POINTER_OFFSET		0x08
248 #define	SBP2_DOORBELL_OFFSET		0x10
249 #define	SBP2_UNSOLICITED_STATUS_ENABLE_OFFSET 0x14
250 
251 /* agent states */
252 #define	SBP2_AGENT_STATE_RESET		0
253 #define	SBP2_AGENT_STATE_ACTIVE		1
254 #define	SBP2_AGENT_STATE_SUSPENDED	2
255 #define	SBP2_AGENT_STATE_DEAD		3
256 
257 /* page table parameters */
258 #define	SBP2_PT_ENT_SIZE		8		/* table entry size */
259 #define	SBP2_PT_SEGSIZE_MAX		(65536 - 8)	/* max segment size */
260 
261 /* page table element for unrestricted page table (ref: 5.2.1) */
262 typedef struct sbp2_pt_unrestricted {
263 	uint16_t	pt_seg_len;	/* segment length */
264 	uint16_t	pt_seg_base_hi;	/* segment base hi */
265 	uint32_t	pt_seg_base_lo;	/* segment base lo */
266 } sbp2_pt_unrestricted_t;
267 
268 /*
269  * Configuration ROM
270  *
271  * key types & values
272  */
273 #define	SBP2_KT_MGT_AGENT		1
274 #define	SBP2_KV_MGT_AGENT		0x14
275 #define	SBP2_KT_LUN			0
276 #define	SBP2_KV_LUN			0x14
277 #define	SBP2_KT_UNCHAR			0
278 #define	SBP2_KV_UNCHAR			0x3A
279 
280 /* Logical_Unit_Number */
281 #define	SBP2_LUN_TYPE			0x001F0000	/* device_type */
282 #define	SBP2_LUN_TYPE_SHIFT		16
283 #define	SBP2_LUN_NUM			0x0000FFFF	/* lun */
284 
285 /* Unit_Characteristics */
286 #define	SBP2_UNCHAR_MOT			0x0000FF00	/* mgt_ORB_timeout */
287 #define	SBP2_UNCHAR_MOT_SHIFT		8
288 #define	SBP2_UNCHAR_ORB_SIZE		0x000000FF	/* ORB_size */
289 
290 
291 _NOTE(SCHEME_PROTECTS_DATA("unique per ORB", { sbp2_dummy_orb sbp2_cmd_orb
292     sbp2_mgt_orb sbp2_login_orb sbp2_login_resp sbp2_qlogins_orb
293     sbp2_reconnect_orb sbp2_logout_orb sbp2_task_mgt_orb sbp2_status
294     sbp2_pt_unrestricted }))
295 
296 #ifdef	__cplusplus
297 }
298 #endif
299 
300 #endif	/* _SYS_SBP2_DEFS_H */
301