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