xref: /haiku/headers/os/device/CAM.h (revision 51978af14a173e7fae0563b562be5603bc652aeb)
1 /* ++++++++++
2 	CAM.h
3 	Copyright (c) 1996-98 by Be Incorporated.  All Rights Reserved.
4 
5 	Definitions for the SCSI Common Access Method as implemented in the Be OS.
6 
7 	See also "Draft Proposed American National Standard, SCSI-2 Common
8 	Access Method Transport and SCSI Interface Module", Revision 12,
9 	ANSI refernce number X3.232-199x.
10 
11 	This file consists of the definitions for the fictional "UNIVOS"
12 	operating system described in the standard.  The file is mostly
13 	the same text as the standard, with Be-provided additions as needed.
14 +++++ */
15 
16 
17 #ifndef _CAM_H
18 #define _CAM_H
19 
20 #include <bus_manager.h>
21 
22 /* ---
23    Be-provided additions to the standard include file.
24 --- */
25 
26 #include <sys/types.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #ifndef U32
33 typedef unsigned long U32;
34 #endif
35 
36 #ifndef I32
37 typedef long I32;
38 #endif
39 
40 #ifndef U16
41 typedef unsigned short U16;
42 #endif
43 
44 typedef struct {
45 	uint32 serial;  /* operation serial number                    */
46 	uint32 micros;  /* operation time in microseconds (4294s max) */
47 	uint32 bytes;   /* number of bytes to transfer                */
48 	uchar path;     /* target SIM ID                              */
49 	uchar target;   /* target device ID                           */
50 	uchar sgcount;  /* # of sg segments (0 if non-sg operation)   */
51 	uchar scsi_op;  /* scsi operation byte                        */
52 } cam_iostat;
53 
54 
55 /* -----
56    The rest of this file contains the definitions and data structures for
57    the CAM Subsystem interface.  The contents of this file should match the
58    data structures and constants that are specified in the CAM document
59 ----- */
60 
61 /* Defines for the XPT function codes, Table 8-2 in the CAM spec. */
62 
63 /* Common function commands, 0x00 - 0x0F */
64 #define XPT_NOOP		0x00	/* Execute Nothing */
65 #define XPT_SCSI_IO		0x01	/* Execute the requested SCSI IO */
66 #define XPT_GDEV_TYPE	0x02	/* Get the device type information */
67 #define XPT_PATH_INQ	0x03	/* Path Inquiry */
68 #define XPT_REL_SIMQ	0x04	/* Release the SIM queue that is frozen */
69 #define XPT_SASYNC_CB	0x05	/* Set Async callback parameters */
70 #define XPT_SDEV_TYPE	0x06	/* Set the device type information */
71 #define XPT_SCAN_BUS	0x07	/* Scan the Scsi Bus */
72 
73 /* XPT SCSI control functions, 0x10 - 0x1F */
74 #define XPT_ABORT		0x10	/* Abort the selected CCB */
75 #define XPT_RESET_BUS	0x11	/* Reset the SCSI bus */
76 #define XPT_RESET_DEV	0x12	/* Reset the SCSI device, BDR */
77 #define XPT_TERM_IO		0x13	/* Terminate the I/O process */
78 
79 /* HBA engine commands, 0x20 - 0x2F */
80 #define XPT_ENG_INQ		0x20	/* HBA engine inquiry */
81 #define XPT_ENG_EXEC	0x21	/* HBA execute engine request */
82 
83 /* Target mode commands, 0x30 - 0x3F */
84 #define XPT_EN_LUN		0x30	/* Enable LUN, Target mode support */
85 #define XPT_TARGET_IO	0x31	/* Execute the target IO request */
86 #define XPT_ACCEPT_TARG 0x32	/* Accept Host Target Mode CDB */
87 #define XPT_CONT_TARG	0x33	/* Cont. Host Target I/O Connection */
88 #define XPT_IMMED_NOTIFY 0x34	/* Notify Host Target driver of event*/
89 #define XPT_NOTIFY_ACK	0x35	/* Acknowledgement of event */
90 
91 #define XPT_FUNC		0x7F	/* TEMPLATE */
92 #define XPT_VUNIQUE		0x80	/* All the rest are vendor unique commands */
93 
94 /* ---------------------------------------------------------------------- */
95 
96 /* General allocation length defines for the CCB structures. */
97 
98 #define IOCDBLEN	12	/* Space for the CDB bytes/pointer */
99 #define VUHBA		14	/* Vendor Unique HBA length */
100 #define SIM_ID		16	/* ASCII string len for SIM ID */
101 #define HBA_ID		16	/* ASCII string len for HBA ID */
102 
103 #define BE_SIM_CCB_SIZE 1536    /* we want to allocate 1.5k chunks */
104 #define BE_SIM_SCSIIO_SIZE 88   /* sizeof(CAM_CCB_SCSIIO) - SIM_PRIV */
105 #define SIM_PRIV	(BE_SIM_CCB_SIZE - BE_SIM_SCSIIO_SIZE) /* Length of SIM private data area */
106 
107 /* SIM_PRIV (sim private data area)  Terms and Conditions:
108 
109  - the size of SIM_PRIV shall be such that sizeof(CCB_SIZE_UNION) = 1.5k
110  - all CCB's shall be allocated from locked, contiguous memory
111  - CCB's shall be aligned on 512 byte boundaries
112  - SIM_PRIV will be >= 1408 bytes
113  - this provides 128  8byte sg entries (512mb worth of pages, worstcase fragmentation)
114  - and 256 bytes for sense data and 128 bytes for whatever else the SIM needs
115 
116  - These conditions are NULL and (void) where prohibited by law.
117  - All sales are final.
118  - Do not use near open flame.
119 */
120 
121 /* Structure definitions for the CAM control blocks, CCB's for the
122 subsystem. */
123 
124 /* Common CCB header definition. */
125 typedef struct ccb_header
126 {
127 	uint32          phys_addr;      /* physical address of this CCB */
128 	uint16			cam_ccb_len;	/* Length of the entire CCB */
129 	uchar			cam_func_code;	/* XPT function code */
130 	uchar			cam_status;		/* Returned CAM subsystem status */
131 	uchar			cam_hrsvd0;		/* Reserved field, for alignment */
132 	uchar			cam_path_id;	/* Path ID for the request */
133 	uchar			cam_target_id;	/* Target device ID */
134 	uchar			cam_target_lun;	/* Target LUN number */
135 	uint32			cam_flags;		/* Flags for operation of the subsystem */
136 } CCB_HEADER;
137 
138 /* Common SCSI functions. */
139 
140 /* Union definition for the CDB space in the SCSI I/O request CCB */
141 typedef union cdb_un
142 {
143 	uchar	*cam_cdb_ptr;				/* Pointer to the CDB bytes to send */
144 	uchar	cam_cdb_bytes[ IOCDBLEN ];	/* Area for the CDB to send */
145 } CDB_UN;
146 
147 /* Get device type CCB */
148 typedef struct ccb_getdev
149 {
150 	CCB_HEADER	cam_ch;					/* Header information fields */
151 	char		*cam_inq_data;			/* Ptr to the inquiry data space */
152 	uchar		cam_pd_type;			/* Periph device type from the TLUN */
153 } CCB_GETDEV;
154 
155 /* Path inquiry CCB */
156 typedef struct ccb_pathinq
157 {
158 	CCB_HEADER	cam_ch;						/* Header information fields */
159 	uchar		cam_version_num;			/* Version number for the SIM/HBA */
160 	uchar		cam_hba_inquiry;			/* Mimic of INQ byte 7 for the HBA */
161 	uchar		cam_target_sprt;			/* Flags for target mode support */
162 	uchar		cam_hba_misc;				/* Misc HBA feature flags */
163 	uint16		cam_hba_eng_cnt;			/* HBA engine count */
164 	uchar		cam_vuhba_flags[ VUHBA ];	/* Vendor unique capabilities */
165 	uint32		cam_sim_priv;				/* Size of SIM private data area */
166 	uint32		cam_async_flags;			/* Event cap. for Async Callback */
167 	uchar		cam_hpath_id;				/* Highest path ID in the subsystem */
168 	uchar		cam_initiator_id;			/* ID of the HBA on the SCSI bus */
169 	uchar		cam_prsvd0;					/* Reserved field, for alignment */
170 	uchar		cam_prsvd1;					/* Reserved field, for alignment */
171 	char		cam_sim_vid[ SIM_ID ];		/* Vendor ID of the SIM */
172 	char		cam_hba_vid[ HBA_ID ];		/* Vendor ID of the HBA */
173 	uchar		*cam_osd_usage;				/* Ptr for the OSD specific area */
174 } CCB_PATHINQ;
175 
176 /* Release SIM Queue CCB */
177 typedef struct ccb_relsim
178 {
179 	CCB_HEADER	cam_ch;						/* Header information fields */
180 } CCB_RELSIM;
181 
182 /* SCSI I/O Request CCB */
183 typedef struct ccb_scsiio
184 {
185 	CCB_HEADER	cam_ch;					/* Header information fields */
186 	uchar		*cam_pdrv_ptr;			/* Ptr used by the Peripheral driver */
187 	CCB_HEADER	*cam_next_ccb;			/* Ptr to the next CCB for action */
188 	uchar		*cam_req_map;			/* Ptr for mapping info on the Req. */
189 	void		(*cam_cbfcnp)(struct ccb_scsiio *);
190 	                                    /* Callback on completion function */
191 	uchar		*cam_data_ptr;			/* Pointer to the data buf/SG list */
192 	uint32		cam_dxfer_len;			/* Data xfer length */
193 	uchar		*cam_sense_ptr;			/* Pointer to the sense data buffer */
194 	uchar		cam_sense_len;			/* Num of bytes in the Autosense buf */
195 	uchar		cam_cdb_len;			/* Number of bytes for the CDB */
196 	uint16		cam_sglist_cnt;			/* Num of scatter gather list entries */
197 	uint32		cam_sort;				/* Value used by SIM to sort on */
198 	uchar		cam_scsi_status;		/* Returned scsi device status */
199 	uchar		cam_sense_resid;		/* Autosense resid length: 2's comp */
200 	uchar		cam_osd_rsvd1[2];		/* OSD Reserved field, for alignment */
201 	int32		cam_resid;				/* Transfer residual length: 2's comp */
202 	CDB_UN		cam_cdb_io;				/* Union for CDB bytes/pointer */
203 	uint32		cam_timeout;			/* Timeout value */
204 	uchar		*cam_msg_ptr;			/* Pointer to the message buffer */
205 	uint16		cam_msgb_len;			/* Num of bytes in the message buf */
206 	uint16		cam_vu_flags;			/* Vendor unique flags */
207 	uchar		cam_tag_action;			/* What to do for tag queuing */
208 	uchar		cam_iorsvd0[3];			/* Reserved field, for alignment */
209 	uchar		cam_sim_priv[ SIM_PRIV ];	/* SIM private data area */
210 } CCB_SCSIIO;
211 
212 /* Set Async Callback CCB */
213 typedef struct ccb_setasync
214 {
215 	CCB_HEADER	cam_ch;					/* Header information fields */
216 	uint32		cam_async_flags;		/* Event enables for Callback resp */
217 	void		(*cam_async_func)();	/* Async Callback function address */
218 	uchar		*pdrv_buf;				/* Buffer set aside by the Per. drv */
219 	uchar		pdrv_buf_len;			/* The size of the buffer */
220 } CCB_SETASYNC;
221 
222 /* Set device type CCB */
223 typedef struct ccb_setdev
224 {
225 	CCB_HEADER	 cam_ch;				/* Header information fields */
226 	uchar		cam_dev_type;			/* Val for the dev type field in EDT */
227 } CCB_SETDEV;
228 
229 /* SCSI Control Functions. */
230 
231 /* Abort XPT Request CCB */
232 typedef struct ccb_abort
233 {
234 	CCB_HEADER	cam_ch;					/* Header information fields */
235 	CCB_HEADER	*cam_abort_ch;			/* Pointer to the CCB to abort */
236 } CCB_ABORT;
237 
238 /* Reset SCSI Bus CCB */
239 typedef struct ccb_resetbus
240 {
241 	CCB_HEADER	cam_ch;					/* Header information fields */
242 } CCB_RESETBUS;
243 
244 /* Reset SCSI Device CCB */
245 typedef struct ccb_resetdev
246 {
247 	CCB_HEADER	cam_ch;					/* Header information fields */
248 } CCB_RESETDEV;
249 
250 /* Terminate I/O Process Request CCB */
251 typedef struct ccb_termio
252 {
253 	CCB_HEADER	cam_ch;					/* Header information fields */
254 	CCB_HEADER	*cam_termio_ch;			/* Pointer to the CCB to terminate */
255 } CCB_TERMIO;
256 
257 /* Target mode structures. */
258 
259 /* Host Target Mode Version 1 Enable LUN CCB */
260 typedef struct ccb_en_lun
261 {
262 	CCB_HEADER	cam_ch;					/* Header information fields */
263 	uint16		cam_grp6_len;			/* Group 6 VU CDB length */
264 	uint16		cam_grp7_len;			/* Group 7 VU CDB length */
265 	uchar		*cam_ccb_listptr;		/* Pointer to the target CCB list */
266 	uint16		cam_ccb_listcnt;		/* Count of Target CCBs in the list */
267 } CCB_EN_LUN;
268 
269 /* Enable LUN CCB (HTM V2) */
270 typedef struct ccb_enable_lun
271 {
272 	CCB_HEADER	cam_ch;					/* Header information fields */
273 	uint16		cam_grp6_length;		/* Group 6 Vendor Unique CDB Lengths */
274 	uint16		cam_grp7_length;		/* Group 7 Vendor Unique CDB Lengths */
275 	uchar		*cam_immed_notify_list;	/* Ptr to Immediate Notify CCB list */
276 	uint32		cam_immed_notify_cnt;	/* Number of Immediate Notify CCBs */
277 	uchar		*cam_accept_targ_list;	/* Ptr to Accept Target I/O CCB list */
278 	uint32		cam_accept_targ_cnt;	/* Number of Accept Target I/O CCBs */
279 	uchar		cam_sim_priv[ SIM_PRIV ]; /* SIM private data area */
280 } CCB_ENABLE_LUN;
281 
282 /* Immediate Notify CCB */
283 typedef struct ccb_immed_notify
284 {
285 	CCB_HEADER	cam_ch;					/* Header information fields */
286 	uchar		*cam_pdrv_ptr;			/* Ptr used by the Peripheral driver */
287 	void		(*cam_cbfnot)();		/* Callback on notification function */
288 	uchar		*cam_sense_ptr;			/* Pointer to the sense data buffer */
289 	uchar		cam_sense_len;			/* Num of bytes in the Autosense buf */
290 	uchar		cam_init_id;			/* ID of Initiator that selected */
291 	uint16		cam_seq_id;				/* Sequence Identifier */
292 	uchar		cam_msg_code;			/* Message Code */
293 	uchar		cam_msg_args[7];		/* Message Arguments */
294 } CCB_IMMED_NOTIFY;
295 
296 /* Notify Acknowledge CCB */
297 typedef struct ccb_notify_ack
298 {
299 	CCB_HEADER	cam_ch;					/* Header information fields */
300 	uint16		cam_seq_id;				/* Sequence Identifier */
301 	uchar		cam_event;				/* Event */
302 	uchar		cam_rsvd;
303 } CCB_NOTIFY_ACK;
304 
305 /* Accept Target I/O CCB */
306 typedef struct ccb_accept_targ
307 {
308 	CCB_HEADER	cam_ch;					/* Header information fields */
309 	uchar		*cam_pdrv_ptr;			/* Ptr used by the Peripheral driver */
310 	CCB_HEADER	*cam_next_ccb;			/* Ptr to the next CCB for action */
311 	uchar		*cam_req_map;			/* Ptr for mapping info on the Req. */
312 	void		(*cam_cbfcnot)();		/* Callback on completion function */
313 	uchar		*cam_data_ptr;			/* Pointer to the data buf/SG list */
314 	uint32		cam_dxfer_len;			/* Data xfer length */
315 	uchar		*cam_sense_ptr;			/* Pointer to the sense data buffer */
316 	uchar		cam_sense_len;			/* Num of bytes in the Autosense buf */
317 	uchar		cam_cdb_len;			/* Number of bytes for the CDB */
318 	uint16		cam_sglist_cnt;			/* Num of scatter gather list entries */
319 	uint32  	cam_sort;				/* Value used by SIM to sort on */
320 	uchar		cam_scsi_status;		/* Returned scsi device status */
321 	uchar		cam_sense_resid;		/* Autosense resid length: 2's comp */
322 	uchar		cam_osd_rsvd1[2];		/* OSD Reserved field, for alignment */
323 	int32		cam_resid;				/* Transfer residual length: 2's comp */
324 	CDB_UN		cam_cdb_io;				/* Union for CDB bytes/pointer */
325 	uint32		cam_timeout;			/* Timeout value */
326 	uchar		*cam_msg_ptr;			/* Pointer to the message buffer */
327 	uint16		cam_msgb_len;			/* Num of bytes in the message buf */
328 	uint16		cam_vu_flags;			/* Vendor unique flags */
329 	uchar		cam_tag_action;			/* What to do for tag queuing */
330 	uchar		cam_tag_id;				/* Tag ID */
331 	uchar		cam_initiator_id;		/* Initiator ID */
332 	uchar		cam_iorsvd0[1];			/* Reserved field, for alignment */
333 	uchar		cam_sim_priv[ SIM_PRIV ]; /* SIM private data area */
334 } CCB_ACCEPT_TARG;
335 
336 /* Continue Target I/O CCB */
337 typedef CCB_ACCEPT_TARG CCB_CONT_TARG;
338 
339 /* HBA engine structures. */
340 
341 typedef struct ccb_eng_inq
342 {
343 	CCB_HEADER	cam_ch;					/* Header information fields */
344 	uint16		cam_eng_num;			/* The number for this inquiry */
345 	uchar		cam_eng_type;			/* Returned engine type */
346 	uchar		cam_eng_algo;			/* Returned algorithm type */
347 	uint32		cam_eng_memory;			/* Returned engine memory size */
348 } CCB_ENG_INQ;
349 
350 typedef struct ccb_eng_exec	/* NOTE: must match SCSIIO size */
351 {
352 	CCB_HEADER	cam_ch;					/* Header information fields */
353 	uchar		*cam_pdrv_ptr;			/* Ptr used by the Peripheral driver */
354 	uint32		cam_engrsvd0;			/* Reserved field, for alignment */
355 	uchar		*cam_req_map;			/* Ptr for mapping info on the Req. */
356 	void		(*cam_cbfcnp)();		/* Callback on completion function */
357 	uchar		*cam_data_ptr;			/* Pointer to the data buf/SG list */
358 	uint32		cam_dxfer_len;			/* Data xfer length */
359 	uchar		*cam_engdata_ptr;		/* Pointer to the engine buffer data */
360 	uchar		cam_engrsvd1;			/* Reserved field, for alignment */
361 	uchar		cam_engrsvd2;			/* Reserved field, for alignment */
362 	uint16		cam_sglist_cnt;			/* Num of scatter gather list entries */
363 	uint32		cam_dmax_len;			/* Destination data maximum length */
364 	uint32		cam_dest_len;			/* Destination data length */
365 	int32		cam_src_resid;			/* Source residual length: 2's comp */
366 	uchar		cam_engrsvd3[12];		/* Reserved field, for alignment */
367 	uint32		cam_timeout;			/* Timeout value */
368 	uint32		cam_engrsvd4;			/* Reserved field, for alignment */
369 	uint16		cam_eng_num;			/* Engine number for this request */
370 	uint16		cam_vu_flags;			/* Vendor unique flags */
371 	uchar		cam_engrsvd5;			/* Reserved field, for alignment */
372 	uchar		cam_engrsvd6[3];		/* Reserved field, for alignment */
373 	uchar		cam_sim_priv[ SIM_PRIV ]; /* SIM private data area */
374 } CCB_ENG_EXEC;
375 
376 /* The sim_module_info definition is used to define the entry points for
377 the SIMs contained in the SCSI CAM subsystem.	Each SIM file will
378 contain a declaration for it's entry.	The address for this entry will
379 be stored in the cam_conftbl[] array along will all the other SIM
380 entries. */
381 
382 typedef struct sim_module_info sim_module_info;
383 
384 struct sim_module_info {
385 	module_info		minfo;
386 };
387 
388 typedef struct CAM_SIM_ENTRY CAM_SIM_ENTRY;
389 
390 struct CAM_SIM_ENTRY {
391 	status_t		(*sim_init)();
392 	int32			(*sim_action)();
393 };
394 
395 /* ---------------------------------------------------------------------- */
396 
397 /* Defines for the CAM status field in the CCB header. */
398 
399 #define	CAM_REQ_INPROG			0x00	/* CCB request is in progress */
400 #define CAM_REQ_CMP 			0x01	/* CCB request completed w/out error */
401 #define CAM_REQ_ABORTED			0x02	/* CCB request aborted by the host */
402 #define CAM_UA_ABORT			0x03	/* Unable to Abort CCB request */
403 #define CAM_REQ_CMP_ERR			0x04	/* CCB request completed with an err */
404 #define CAM_BUSY				0x05	/* CAM subsystem is busy */
405 #define CAM_REQ_INVALID			0x06	/* CCB request is invalid */
406 #define CAM_PATH_INVALID		0x07	/* Path ID supplied is invalid */
407 #define CAM_DEV_NOT_THERE		0x08	/* SCSI device not installed/there */
408 #define CAM_UA_TERMIO			0x09	/* Unable to Terminate I/O CCB req */
409 #define CAM_SEL_TIMEOUT			0x0A	/* Target selection timeout */
410 #define CAM_CMD_TIMEOUT			0x0B	/* Command timeout */
411 #define CAM_MSG_REJECT_REC		0x0D	/* Message reject received */
412 #define CAM_SCSI_BUS_RESET		0x0E	/* SCSI bus reset sent/received */
413 #define CAM_UNCOR_PARITY		0x0F	/* Uncorrectable parity err occurred */
414 #define CAM_AUTOSENSE_FAIL		0x10	/* Autosense: Request sense cmd fail */
415 #define CAM_NO_HBA				0x11	/* No HBA detected Error */
416 #define CAM_DATA_RUN_ERR		0x12	/* Data overrun/underrun error */
417 #define CAM_UNEXP_BUSFREE		0x13	/* Unexpected BUS free */
418 #define CAM_SEQUENCE_FAIL		0x14	/* Target bus phase sequence failure */
419 #define CAM_CCB_LEN_ERR			0x15	/* CCB length supplied is inadequate */
420 #define CAM_PROVIDE_FAIL		0x16	/* Unable to provide requ. capability */
421 #define CAM_BDR_SENT			0x17	/* A SCSI BDR msg was sent to target */
422 #define CAM_REQ_TERMIO			0x18	/* CCB request terminated by the host */
423 #define CAM_HBA_ERR				0x19	/* Unrecoverable host bus adaptor err*/
424 #define CAM_BUS_RESET_DENIED	0x1A	/* SCSI bus reset denied */
425 
426 #define CAM_IDE					0x33	/* Initiator Detected Error Received */
427 #define CAM_RESRC_UNAVAIL		0x34	/* Resource unavailable */
428 #define CAM_UNACKED_EVENT		0x35	/* Unacknowledged event by host */
429 #define CAM_MESSAGE_RECV		0x36	/* Msg received in Host Target Mode */
430 #define CAM_INVALID_CDB			0x37	/* Invalid CDB recvd in HT Mode */
431 #define CAM_LUN_INVALID			0x38	/* LUN supplied is invalid */
432 #define CAM_TID_INVALID			0x39	/* Target ID supplied is invalid */
433 #define CAM_FUNC_NOTAVAIL		0x3A	/* The requ. func is not available */
434 #define CAM_NO_NEXUS			0x3B	/* Nexus is not established */
435 #define CAM_IID_INVALID			0x3C	/* The initiator ID is invalid */
436 #define CAM_CDB_RECVD			0x3D	/* The SCSI CDB has been received */
437 #define CAM_LUN_ALLREADY_ENAB	0x3E	/* LUN already enabled */
438 #define CAM_SCSI_BUSY			0x3F	/* SCSI bus busy */
439 
440 #define CAM_SIM_QFRZN			0x40	/* The SIM queue is frozen w/this err */
441 #define CAM_AUTOSNS_VALID		0x80	/* Autosense data valid for target */
442 
443 #define CAM_STATUS_MASK			0x3F	/* Mask bits for just the status # */
444 
445 /* ---------------------------------------------------------------------- */
446 
447 /* Defines for the CAM flags field in the CCB header. */
448 
449 #define CAM_DIR_RESV			0x00000000	/* Data direction (00: reserved) */
450 #define CAM_DIR_IN				0x00000040	/* Data direction (01: DATA IN) */
451 #define CAM_DIR_OUT				0x00000080	/* Data direction (10: DATA OUT) */
452 #define CAM_DIR_NONE			0x000000C0	/* Data direction (11: no data) */
453 #define CAM_DIS_AUTOSENSE		0x00000020	/* Disable autosense feature */
454 #define CAM_SCATTER_VALID		0x00000010	/* Scatter/gather list is valid */
455 #define CAM_DIS_CALLBACK		0x00000008	/* Disable callback feature */
456 #define CAM_CDB_LINKED			0x00000004	/* The CCB contains a linked CDB */
457 #define CAM_QUEUE_ENABLE		0x00000002	/* SIM queue actions are enabled */
458 #define CAM_CDB_POINTER			0x00000001	/* The CDB field contains a pointer */
459 
460 #define CAM_DIS_DISCONNECT 		0x00008000	/* Disable disconnect */
461 #define CAM_INITIATE_SYNC		0x00004000	/* Attempt Sync data xfer, and SDTR */
462 #define CAM_DIS_SYNC			0x00002000	/* Disable sync, go to async */
463 #define CAM_SIM_QHEAD			0x00001000	/* Place CCB at the head of SIM Q */
464 #define CAM_SIM_QFREEZE			0x00000800	/* Return the SIM Q to frozen state */
465 #define CAM_SIM_QFRZDIS			0x00000400	/* Disable the SIM Q frozen state */
466 #define CAM_ENG_SYNC			0x00000200	/* Flush resid bytes before cmplt */
467 
468 #define CAM_ENG_SGLIST			0x00800000	/* The SG list is for the HBA engine */
469 #define CAM_CDB_PHYS			0x00400000	/* CDB pointer is physical */
470 #define CAM_DATA_PHYS			0x00200000	/* SG/Buffer data ptrs are physical */
471 #define CAM_SNS_BUF_PHYS		0x00100000	/* Autosense data ptr is physical */
472 #define CAM_MSG_BUF_PHYS		0x00080000	/* Message buffer ptr is physical */
473 #define CAM_NXT_CCB_PHYS		0x00040000	/* Next CCB pointer is physical */
474 #define CAM_CALLBCK_PHYS		0x00020000	/* Callback func ptr is physical */
475 
476 #define CAM_SEND_STATUS			0x80000000	/* Send status after date phase */
477 #define CAM_DISCONNECT			0x40000000	/* Disc. mandatory after cdb recv */
478 #define CAM_TERM_IO				0x20000000	/* Terminate I/O Message supported */
479 
480 #define CAM_DATAB_VALID			0x80000000	/* Data buffer valid */
481 #define CAM_STATUS_VALID		0x40000000	/* Status buffer valid */
482 #define CAM_MSGB_VALID			0x20000000	/* Message buffer valid */
483 #define CAM_TGT_PHASE_MODE 		0x08000000	/* The SIM will run in phase mode */
484 #define CAM_TGT_CCB_AVAIL		0x04000000	/* Target CCB available */
485 #define CAM_DIS_AUTODISC		0x02000000	/* Disable autodisconnect */
486 #define CAM_DIS_AUTOSRP			0x01000000	/* Disable autosave/restore ptrs */
487 
488 /* ---------------------------------------------------------------------- */
489 
490 /* Defines for the SIM/HBA queue actions.	These value are used in the
491 SCSI I/O CCB, for the queue action field. [These values should match the
492 defines from some other include file for the SCSI message phases.	We may
493 not need these definitions here. ] */
494 
495 #define CAM_SIMPLE_QTAG			0x20		/* Tag for a simple queue */
496 #define CAM_HEAD_QTAG			0x21		/* Tag for head of queue */
497 #define CAM_ORDERED_QTAG		0x22		/* Tag for ordered queue */
498 
499 /* ---------------------------------------------------------------------- */
500 
501 /* Defines for the timeout field in the SCSI I/O CCB.	At this time a value
502 of 0xF-F indicates a infinite timeout.	A value of 0x0-0 indicates that the
503 SIM's default timeout can take effect. */
504 
505 #define CAM_TIME_DEFAULT		0x00000000	/* Use SIM default value */
506 #define CAM_TIME_INFINITY		0xFFFFFFFF	/* Infinite timeout for I/O */
507 
508 /* ---------------------------------------------------------------------- */
509 
510 /* Defines for the Path Inquiry CCB fields. */
511 
512 #define	CAM_VERSION				0x25	/* Binary value for the current ver */
513 
514 #define PI_MDP_ABLE				0x80	/* Supports MDP message */
515 #define PI_WIDE_32				0x40	/* Supports 32 bit wide SCSI */
516 #define PI_WIDE_16				0x20	/* Supports 16 bit wide SCSI */
517 #define PI_SDTR_ABLE			0x10	/* Supports SDTR message */
518 #define PI_LINKED_CDB			0x08	/* Supports linked CDBs */
519 #define PI_TAG_ABLE				0x02	/* Supports tag queue message */
520 #define PI_SOFT_RST				0x01	/* Supports soft reset */
521 
522 #define PIT_PROCESSOR			0x80	/* Target mode processor mode */
523 #define PIT_PHASE				0x40	/* Target mode phase cog. mode */
524 
525 #define PIM_SCANHILO			0x80	/* Bus scans from ID 7 to ID 0 */
526 #define PIM_NOREMOVE			0x40	/* Removable dev not included in scan */
527 #define PIM_NOINQUIRY			0x20	/* Inquiry data not kept by XPT */
528 
529 /* ---------------------------------------------------------------------- */
530 
531 /* Defines for Asynchronous Callback CCB fields. */
532 
533 #define AC_FOUND_DEVICES		0x80	/* During a rescan new device found */
534 #define AC_SIM_DEREGISTER		0x40	/* A loaded SIM has de-registered */
535 #define AC_SIM_REGISTER			0x20	/* A loaded SIM has registered */
536 #define AC_SENT_BDR				0x10	/* A BDR message was sent to target */
537 #define AC_SCSI_AEN				0x08	/* A SCSI AEN has been received */
538 #define AC_UNSOL_RESEL			0x02	/* A unsolicited reselection occurred */
539 #define AC_BUS_RESET			0x01	/* A SCSI bus RESET occurred */
540 
541 /* ---------------------------------------------------------------------- */
542 
543 /* Typedef for a scatter/gather list element. */
544 
545 typedef struct sg_elem
546 {
547 	uchar		*cam_sg_address;		/* Scatter/Gather address */
548 	uint32		cam_sg_count;			/* Scatter/Gather count */
549 } SG_ELEM;
550 
551 /* ---------------------------------------------------------------------- */
552 
553 /* Defines for the "event" field in the CCB_NOTIFY_ACK */
554 #define CAM_RESET_CLEARED		0x80	/* Reset Cleared */
555 
556 /* ---------------------------------------------------------------------- */
557 
558 /* Defines for the HBA engine inquiry CCB fields. */
559 
560 #define EIT_BUFFER				0x00	/* Engine type: Buffer memory */
561 #define EIT_LOSSLESS			0x01	/* Engine type: Lossless compression */
562 #define EIT_LOSSLY				0x02	/* Engine type: Lossly compression */
563 #define EIT_ENCRYPT				0x03	/* Engine type: Encryption */
564 
565 #define EAD_VUNIQUE				0x00	/* Eng algorithm ID: vendor unique */
566 #define EAD_LZ1V1				0x00	/* Eng algorithm ID: LZ1 var. 1*/
567 #define EAD_LZ2V1				0x00	/* Eng algorithm ID: LZ2 var. 1*/
568 #define EAD_LZ2V2				0x00	/* Eng algorithm ID: LZ2 var. 2*/
569 
570 /* ---------------------------------------------------------------------- */
571 /* ---------------------------------------------------------------------- */
572 
573 /* Unix OSD defines and data structures. */
574 
575 #define INQLEN	36		/* Inquiry string length to store. */
576 
577 #define CAM_SUCCESS	0	/* For signaling general success */
578 #define CAM_FAILURE	1	/* For signaling general failure */
579 
580 #define CAM_FALSE	0	/* General purpose flag value */
581 #define CAM_TRUE	1	/* General purpose flag value */
582 
583 #define XPT_CCB_INVALID	-1	/* for signaling a bad CCB to free */
584 
585 /* The typedef for the Async callback information.	This structure is used to
586 store the supplied info from the Set Async Callback CCB, in the EDT table
587 in a linked list structure. */
588 
589 typedef struct async_info
590 {
591 	struct async_info	*cam_async_next;		/* pointer to the next structure */
592 	uint32				cam_event_enable;		/* Event enables for Callback resp */
593 	void				(*cam_async_func)();	/* Async Callback function address */
594 	uint32				cam_async_blen;			/* Length of "information" buffer */
595 	uchar				*cam_async_ptr;			/* Address for the "information */
596 } ASYNC_INFO;
597 
598 /* The CAM EDT table contains the device information for all the
599 devices, SCSI ID and LUN, for all the SCSI busses in the system.	The
600 table contains a CAM_EDT_ENTRY structure for each device on the bus.
601 */
602 
603 typedef struct cam_edt_entry
604 {
605 	int32		cam_tlun_found;			/* Flag for the existence of the target/LUN */
606 	ASYNC_INFO	*cam_ainfo;				/* Async callback list info for this B/T/L */
607 	uint32		cam_owner_tag;			/* Tag for the peripheral driver's ownership */
608 	char		cam_inq_data[ INQLEN ];	/* storage for the inquiry data */
609 } CAM_EDT_ENTRY;
610 
611 
612 /* ============================================================================== */
613 /* ----------------------------- VENDOR UNIQUE DATA ----------------------------- */
614 /* ============================================================================== */
615 
616 /* ---
617 	Vendor unique XPT function codes
618 --- */
619 
620 #define XPT_EXTENDED_PATH_INQ	(XPT_VUNIQUE + 1)		/* Extended Path Inquiry */
621 
622 /* Extended path inquiry CCB */
623 
624 #define FAM_ID		16						/* ASCII string len for FAMILY ID */
625 #define TYPE_ID		16						/* ASCII string len for TYPE ID */
626 #define VERS		 8						/* ASCII string len for SIM & HBA vers */
627 
628 typedef struct ccb_extended_pathinq
629 {
630 	CCB_PATHINQ	cam_path;					/* Default path inquiry */
631 	char		cam_sim_version [ VERS ];	/* SIM version number */
632 	char		cam_hba_version [ VERS ];	/* HBA version number */
633 	char		cam_controller_family [ FAM_ID ]; /* Controller family */
634 	char		cam_controller_type [ TYPE_ID ]; /* Controller type */
635 } CCB_EXTENDED_PATHINQ;
636 
637 
638 /* ---
639 	Vendor unique flags supported by Be OS (cam_vu_flags)
640 --- */
641 
642 enum {
643 	VU_RESERVED_0			=	0x0001,
644 	VU_RESERVED_1			=	0x0002,
645 	VU_DISABLE_SEL_W_ATN	=	0x0004,
646 	VU_RESERVED_4			=	0x0008
647 };
648 
649 
650 /* ---
651 	XPT interface used by SCSI drivers
652 --- */
653 
654 typedef struct cam_for_driver_module_info cam_for_driver_module_info;
655 
656 struct cam_for_driver_module_info {
657 	bus_manager_info	minfo;
658 	CCB_HEADER *		(*xpt_ccb_alloc)(void);
659 	void				(*xpt_ccb_free)(void *ccb);
660 	long				(*xpt_action)(CCB_HEADER *ccbh);
661 };
662 
663 #define	B_CAM_FOR_DRIVER_MODULE_NAME	"bus_managers/scsi/driver/v1"
664 
665 /* ---
666 	XPT interface used by SCSI SIMs
667 --- */
668 
669 typedef struct cam_for_sim_module_info cam_for_sim_module_info;
670 
671 struct cam_for_sim_module_info {
672 	bus_manager_info	minfo;
673 	long				(*xpt_bus_register) (CAM_SIM_ENTRY *sim);
674 	long				(*xpt_bus_deregister) (long path);
675 };
676 
677 #define	B_CAM_FOR_SIM_MODULE_NAME		"bus_managers/scsi/sim/v1"
678 
679 
680 /* General Union for Kernel Space allocation.	Contains all the possible CCB
681 structures.	This union should never be used for manipulating CCB's its only
682 use is for the allocation and deallocation of raw CCB space. */
683 
684 typedef union ccb_size_union
685 {
686 	CCB_SCSIIO			csio;	/* Please keep this first, for debug/print */
687 	CCB_GETDEV			cgd;
688 	CCB_PATHINQ			cpi;
689 	CCB_RELSIM			crs;
690 	CCB_SETASYNC		csa;
691 	CCB_SETDEV			csd;
692 	CCB_ABORT			cab;
693 	CCB_RESETBUS		crb;
694 	CCB_RESETDEV		crd;
695 	CCB_TERMIO			ctio;
696 	CCB_EN_LUN			cel;
697 	CCB_ENABLE_LUN		cel2;
698 	CCB_IMMED_NOTIFY	cin;
699 	CCB_NOTIFY_ACK		cna;
700 	CCB_ACCEPT_TARG		cat;
701 	CCB_ENG_INQ			cei;
702 	CCB_ENG_EXEC		cee;
703 	CCB_EXTENDED_PATHINQ	cdpi;
704 } CCB_SIZE_UNION;
705 
706 
707 #ifdef __cplusplus
708 }
709 #endif
710 
711 #endif
712