1229997Sken/*-
2229997Sken * Copyright (c) 2003 Silicon Graphics International Corp.
3229997Sken * All rights reserved.
4229997Sken *
5229997Sken * Redistribution and use in source and binary forms, with or without
6229997Sken * modification, are permitted provided that the following conditions
7229997Sken * are met:
8229997Sken * 1. Redistributions of source code must retain the above copyright
9229997Sken *    notice, this list of conditions, and the following disclaimer,
10229997Sken *    without modification.
11229997Sken * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12229997Sken *    substantially similar to the "NO WARRANTY" disclaimer below
13229997Sken *    ("Disclaimer") and any redistribution must be conditioned upon
14229997Sken *    including a substantially similar Disclaimer requirement for further
15229997Sken *    binary redistribution.
16229997Sken *
17229997Sken * NO WARRANTY
18229997Sken * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19229997Sken * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20229997Sken * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
21229997Sken * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22229997Sken * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23229997Sken * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24229997Sken * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25229997Sken * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26229997Sken * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27229997Sken * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28229997Sken * POSSIBILITY OF SUCH DAMAGES.
29229997Sken *
30229997Sken * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_io.h#5 $
31229997Sken * $FreeBSD$
32229997Sken */
33229997Sken/*
34229997Sken * CAM Target Layer data movement structures/interface.
35229997Sken *
36229997Sken * Author: Ken Merry <ken@FreeBSD.org>
37229997Sken */
38229997Sken
39229997Sken#ifndef	_CTL_IO_H_
40229997Sken#define	_CTL_IO_H_
41229997Sken
42229997Sken#ifdef _CTL_C
43229997Sken#define EXTERN(__var,__val) __var = __val
44229997Sken#else
45229997Sken#define EXTERN(__var,__val) extern __var
46229997Sken#endif
47229997Sken
48229997Sken#define	CTL_MAX_CDBLEN	32
49229997Sken/*
50229997Sken * Uncomment this next line to enable printing out times for I/Os
51229997Sken * that take longer than CTL_TIME_IO_SECS seconds to get to the datamove
52229997Sken * and/or done stage.
53229997Sken */
54229997Sken#define	CTL_TIME_IO
55229997Sken#ifdef  CTL_TIME_IO
56229997Sken#define	CTL_TIME_IO_DEFAULT_SECS	90
57229997SkenEXTERN(int ctl_time_io_secs, CTL_TIME_IO_DEFAULT_SECS);
58229997Sken#endif
59229997Sken
60229997Sken/*
61229997Sken * Uncomment these next two lines to enable the CTL I/O delay feature.  You
62229997Sken * can delay I/O at two different points -- datamove and done.  This is
63229997Sken * useful for diagnosing abort conditions (for hosts that send an abort on a
64229997Sken * timeout), and for determining how long a host's timeout is.
65229997Sken */
66229997Sken#define	CTL_IO_DELAY
67229997Sken#define	CTL_TIMER_BYTES		sizeof(struct callout)
68229997Sken
69229997Skentypedef enum {
70229997Sken	CTL_STATUS_NONE,	/* No status */
71229997Sken	CTL_SUCCESS,		/* Transaction completed successfully */
72229997Sken	CTL_CMD_TIMEOUT,	/* Command timed out, shouldn't happen here */
73229997Sken	CTL_SEL_TIMEOUT,	/* Selection timeout, shouldn't happen here */
74229997Sken	CTL_ERROR,		/* General CTL error XXX expand on this? */
75229997Sken	CTL_SCSI_ERROR,		/* SCSI error, look at status byte/sense data */
76229997Sken	CTL_CMD_ABORTED,	/* Command aborted, don't return status */
77229997Sken	CTL_STATUS_MASK = 0xfff,/* Mask off any status flags */
78229997Sken	CTL_AUTOSENSE = 0x1000	/* Autosense performed */
79229997Sken} ctl_io_status;
80229997Sken
81229997Sken/*
82229997Sken * WARNING:  Keep the data in/out/none flags where they are.  They're used
83229997Sken * in conjuction with ctl_cmd_flags.  See comment above ctl_cmd_flags
84229997Sken * definition in ctl_private.h.
85229997Sken */
86229997Skentypedef enum {
87229997Sken	CTL_FLAG_NONE		= 0x00000000,	/* no flags */
88229997Sken	CTL_FLAG_DATA_IN	= 0x00000001,	/* DATA IN */
89229997Sken	CTL_FLAG_DATA_OUT	= 0x00000002,	/* DATA OUT */
90229997Sken	CTL_FLAG_DATA_NONE	= 0x00000003,	/* no data */
91229997Sken	CTL_FLAG_DATA_MASK	= 0x00000003,
92229997Sken	CTL_FLAG_KDPTR_SGLIST	= 0x00000008, 	/* kern_data_ptr is S/G list*/
93229997Sken	CTL_FLAG_EDPTR_SGLIST	= 0x00000010,	/* ext_data_ptr is S/G list */
94229997Sken	CTL_FLAG_DO_AUTOSENSE	= 0x00000020,	/* grab sense info */
95229997Sken	CTL_FLAG_USER_REQ	= 0x00000040,	/* request came from userland */
96229997Sken	CTL_FLAG_CONTROL_DEV	= 0x00000080,	/* processor device */
97229997Sken	CTL_FLAG_ALLOCATED	= 0x00000100,	/* data space allocated */
98229997Sken	CTL_FLAG_BLOCKED	= 0x00000200,	/* on the blocked queue */
99229997Sken	CTL_FLAG_ABORT		= 0x00000800,	/* this I/O should be aborted */
100229997Sken	CTL_FLAG_DMA_INPROG	= 0x00001000,	/* DMA in progress */
101229997Sken	CTL_FLAG_NO_DATASYNC	= 0x00002000,	/* don't cache flush data */
102229997Sken	CTL_FLAG_DELAY_DONE	= 0x00004000,	/* delay injection done */
103229997Sken	CTL_FLAG_INT_COPY	= 0x00008000,	/* internal copy, no done call*/
104229997Sken	CTL_FLAG_SENT_2OTHER_SC	= 0x00010000,
105229997Sken	CTL_FLAG_FROM_OTHER_SC	= 0x00020000,
106229997Sken	CTL_FLAG_IS_WAS_ON_RTR  = 0x00040000,	/* Don't rerun cmd on failover*/
107229997Sken	CTL_FLAG_BUS_ADDR	= 0x00080000,	/* ctl_sglist contains BUS
108229997Sken						   addresses, not virtual ones*/
109229997Sken	CTL_FLAG_IO_CONT	= 0x00100000,	/* Continue I/O instead of
110229997Sken						   completing */
111229997Sken	CTL_FLAG_AUTO_MIRROR	= 0x00200000,	/* Automatically use memory
112229997Sken						   from the RC cache mirrored
113229997Sken						   address area. */
114229997Sken#if 0
115229997Sken	CTL_FLAG_ALREADY_DONE	= 0x00200000	/* I/O already completed */
116229997Sken#endif
117229997Sken	CTL_FLAG_NO_DATAMOVE	= 0x00400000,
118229997Sken	CTL_FLAG_DMA_QUEUED	= 0x00800000,	/* DMA queued but not started*/
119229997Sken	CTL_FLAG_STATUS_QUEUED	= 0x01000000,	/* Status queued but not sent*/
120229997Sken
121229997Sken	CTL_FLAG_REDIR_DONE	= 0x02000000,	/* Redirection has already
122229997Sken						   been done. */
123229997Sken	CTL_FLAG_FAILOVER	= 0x04000000,	/* Killed by a failover */
124229997Sken	CTL_FLAG_IO_ACTIVE	= 0x08000000,	/* I/O active on this SC */
125229997Sken	CTL_FLAG_RDMA_MASK	= CTL_FLAG_NO_DATASYNC | CTL_FLAG_BUS_ADDR |
126229997Sken				  CTL_FLAG_AUTO_MIRROR | CTL_FLAG_REDIR_DONE
127229997Sken						/* Flags we care about for
128229997Sken						   remote DMA */
129229997Sken} ctl_io_flags;
130229997Sken
131229997Sken
132229997Skenstruct ctl_lba_len {
133229997Sken	uint64_t lba;
134229997Sken	uint32_t len;
135229997Sken};
136229997Sken
137229997Skenunion ctl_priv {
138229997Sken	uint8_t		bytes[sizeof(uint64_t) * 2];
139229997Sken	uint64_t	integer;
140229997Sken	void		*ptr;
141229997Sken};
142229997Sken
143229997Sken/*
144229997Sken * Number of CTL private areas.
145229997Sken */
146229997Sken#define	CTL_NUM_PRIV	6
147229997Sken
148229997Sken/*
149229997Sken * Which private area are we using for a particular piece of data?
150229997Sken */
151229997Sken#define	CTL_PRIV_LUN		0	/* CTL LUN pointer goes here */
152229997Sken#define	CTL_PRIV_LBA_LEN	1	/* Decoded LBA/len for read/write*/
153229997Sken#define	CTL_PRIV_MODEPAGE	1	/* Modepage info for config write */
154229997Sken#define	CTL_PRIV_BACKEND	2	/* Reserved for block, RAIDCore */
155229997Sken#define	CTL_PRIV_BACKEND_LUN	3	/* Backend LUN pointer */
156229997Sken#define	CTL_PRIV_FRONTEND	4	/* LSI driver, ioctl front end */
157229997Sken#define	CTL_PRIV_USER		5	/* Userland use */
158229997Sken
159229997Sken#define CTL_INVALID_PORTNAME 0xFF
160229997Sken#define CTL_UNMAPPED_IID     0xFF
161229997Sken/*
162229997Sken * XXX KDM this size is for the port_priv variable in struct ctl_io_hdr
163229997Sken * below.  This should be defined in terms of the size of struct
164229997Sken * ctlfe_lun_cmd_info at the moment:
165229997Sken * struct ctlfe_lun_cmd_info {
166229997Sken *	int cur_transfer_index;
167229997Sken * 	ctlfe_cmd_flags flags;
168229997Sken * 	bus_dma_segment_t cam_sglist[32];
169229997Sken * };
170229997Sken *
171229997Sken * This isn't really the way I'd prefer to do it, but it does make some
172229997Sken * sense, AS LONG AS we can guarantee that there will always only be one
173229997Sken * outstanding DMA request per ctl_io.  If that assumption isn't valid,
174229997Sken * then we've got problems.
175229997Sken *
176229997Sken * At some point it may be nice switch CTL over to using CCBs for
177229997Sken * everything.  At that point we can probably use the ATIO/CTIO model, so
178229997Sken * that multiple simultaneous DMAs per command will just work.
179229997Sken *
180229997Sken * Also note that the current size, 600, is appropriate for 64-bit
181229997Sken * architectures, but is overkill for 32-bit architectures.  Need a way to
182229997Sken * figure out the size at compile time, or just get rid of this altogether.
183229997Sken */
184229997Sken#define	CTL_PORT_PRIV_SIZE	600
185229997Sken
186229997Skenstruct ctl_sg_entry {
187229997Sken	void	*addr;
188229997Sken	size_t	len;
189229997Sken};
190229997Sken
191229997Skenstruct ctl_id {
192229997Sken	uint32_t		id;
193229997Sken	uint64_t		wwid[2];
194229997Sken};
195229997Sken
196229997Skentypedef enum {
197229997Sken	CTL_IO_NONE,
198229997Sken	CTL_IO_SCSI,
199229997Sken	CTL_IO_TASK,
200229997Sken} ctl_io_type;
201229997Sken
202229997Skenstruct ctl_nexus {
203229997Sken	struct ctl_id initid;		/* Initiator ID */
204229997Sken	uint32_t targ_port;		/* Target port, filled in by PORT */
205229997Sken	struct ctl_id targ_target;	/* Destination target */
206229997Sken	uint32_t targ_lun;		/* Destination lun */
207229997Sken};
208229997Sken
209229997Skentypedef enum {
210229997Sken	CTL_MSG_SERIALIZE,
211229997Sken	CTL_MSG_R2R,
212229997Sken	CTL_MSG_FINISH_IO,
213229997Sken	CTL_MSG_BAD_JUJU,
214229997Sken	CTL_MSG_MANAGE_TASKS,
215229997Sken	CTL_MSG_PERS_ACTION,
216229997Sken	CTL_MSG_SYNC_FE,
217229997Sken	CTL_MSG_APS_LOCK,
218229997Sken	CTL_MSG_DATAMOVE,
219229997Sken	CTL_MSG_DATAMOVE_DONE
220229997Sken} ctl_msg_type;
221229997Sken
222229997Skenstruct ctl_scsiio;
223229997Sken
224229997Sken#define	CTL_NUM_SG_ENTRIES	9
225229997Sken
226229997Skenstruct ctl_io_hdr {
227229997Sken	uint32_t	  version;	/* interface version XXX */
228229997Sken	ctl_io_type	  io_type;	/* task I/O, SCSI I/O, etc. */
229229997Sken	ctl_msg_type	  msg_type;
230229997Sken	struct ctl_nexus  nexus;	/* Initiator, port, target, lun */
231229997Sken	uint32_t	  iid_indx;	/* the index into the iid mapping */
232229997Sken	uint32_t	  flags;	/* transaction flags */
233229997Sken	uint32_t	  status;	/* transaction status */
234229997Sken	uint32_t	  port_status;	/* trans status, set by PORT, 0 = good*/
235229997Sken	uint32_t	  timeout;	/* timeout in ms */
236229997Sken	uint32_t	  retries;	/* retry count */
237229997Sken#ifdef CTL_IO_DELAY
238229997Sken	uint8_t		  timer_bytes[CTL_TIMER_BYTES]; /* timer kludge */
239229997Sken#endif /* CTL_IO_DELAY */
240229997Sken#ifdef CTL_TIME_IO
241229997Sken	time_t		  start_time;	/* I/O start time */
242229997Sken	struct bintime	  start_bt;	/* Timer start ticks */
243229997Sken	struct bintime	  dma_start_bt;	/* DMA start ticks */
244229997Sken	struct bintime	  dma_bt;	/* DMA total ticks */
245229997Sken	uint32_t	  num_dmas;	/* Number of DMAs */
246229997Sken#endif /* CTL_TIME_IO */
247229997Sken	union ctl_io	  *original_sc;
248229997Sken	union ctl_io	  *serializing_sc;
249229997Sken	void		  *pool;	/* I/O pool */
250229997Sken	union ctl_priv	  ctl_private[CTL_NUM_PRIV];/* CTL private area */
251229997Sken	uint8_t		  port_priv[CTL_PORT_PRIV_SIZE];/* PORT private area*/
252229997Sken	struct ctl_sg_entry remote_sglist[CTL_NUM_SG_ENTRIES];
253229997Sken	struct ctl_sg_entry remote_dma_sglist[CTL_NUM_SG_ENTRIES];
254229997Sken	struct ctl_sg_entry local_sglist[CTL_NUM_SG_ENTRIES];
255229997Sken	struct ctl_sg_entry local_dma_sglist[CTL_NUM_SG_ENTRIES];
256229997Sken	STAILQ_ENTRY(ctl_io_hdr) links;	/* linked list pointer */
257229997Sken	TAILQ_ENTRY(ctl_io_hdr) ooa_links;
258229997Sken	TAILQ_ENTRY(ctl_io_hdr) blocked_links;
259229997Sken};
260229997Sken
261229997Skentypedef enum {
262229997Sken	CTL_TAG_UNTAGGED,
263229997Sken	CTL_TAG_SIMPLE,
264229997Sken	CTL_TAG_ORDERED,
265229997Sken	CTL_TAG_HEAD_OF_QUEUE,
266229997Sken	CTL_TAG_ACA
267229997Sken} ctl_tag_type;
268229997Sken
269229997Skenunion ctl_io;
270229997Sken
271229997Sken/*
272229997Sken * SCSI passthrough I/O structure for the CAM Target Layer.  Note
273229997Sken * that some of these fields are here for completeness, but they aren't
274229997Sken * used in the CTL implementation.  e.g., timeout and retries won't be
275229997Sken * used.
276229997Sken *
277229997Sken * Note:  Make sure the io_hdr is *always* the first element in this
278229997Sken * structure.
279229997Sken */
280229997Skenstruct ctl_scsiio {
281229997Sken	struct ctl_io_hdr io_hdr;	/* common to all I/O types */
282229997Sken	uint32_t   ext_sg_entries;	/* 0 = no S/G list, > 0 = num entries */
283229997Sken	uint8_t	   *ext_data_ptr;	/* data buffer or S/G list */
284229997Sken	uint32_t   ext_data_len;	/* Data transfer length */
285229997Sken	uint32_t   ext_data_filled;	/* Amount of data filled so far */
286229997Sken	uint32_t   kern_sg_entries;	/* 0 = no S/G list, > 0 = num entries */
287229997Sken	uint32_t   rem_sg_entries;	/* 0 = no S/G list, > 0 = num entries */
288229997Sken	uint8_t    *kern_data_ptr;	/* data buffer or S/G list */
289229997Sken	uint32_t   kern_data_len;	/* Length of this S/G list/buffer */
290229997Sken	uint32_t   kern_total_len;	/* Total length of this transaction */
291229997Sken	uint32_t   kern_data_resid;	/* Length left to transfer after this*/
292229997Sken	uint32_t   kern_rel_offset;	/* Byte Offset of this transfer */
293229997Sken	struct     scsi_sense_data sense_data;	/* sense data */
294229997Sken	uint8_t	   sense_len;		/* Returned sense length */
295229997Sken	uint8_t	   scsi_status;		/* SCSI status byte */
296229997Sken	uint8_t	   sense_residual;	/* sense residual length */
297229997Sken	uint32_t   residual;		/* data residual length */
298229997Sken	uint32_t   tag_num;		/* tag number */
299229997Sken	ctl_tag_type tag_type;		/* simple, ordered, head of queue,etc.*/
300229997Sken	uint8_t    cdb_len;		/* CDB length */
301229997Sken	uint8_t	   cdb[CTL_MAX_CDBLEN];	/* CDB */
302229997Sken	int	   (*be_move_done)(union ctl_io *io); /* called by fe */
303229997Sken	int        (*io_cont)(union ctl_io *io); /* to continue processing */
304229997Sken};
305229997Sken
306229997Skentypedef enum {
307229997Sken	CTL_TASK_ABORT_TASK,
308229997Sken	CTL_TASK_ABORT_TASK_SET,
309229997Sken	CTL_TASK_CLEAR_ACA,
310229997Sken	CTL_TASK_CLEAR_TASK_SET,
311229997Sken	CTL_TASK_LUN_RESET,
312229997Sken	CTL_TASK_TARGET_RESET,
313229997Sken	CTL_TASK_BUS_RESET,
314229997Sken	CTL_TASK_PORT_LOGIN,
315229997Sken	CTL_TASK_PORT_LOGOUT
316229997Sken} ctl_task_type;
317229997Sken
318229997Sken/*
319229997Sken * Task management I/O structure.  Aborts, bus resets, etc., are sent using
320229997Sken * this structure.
321229997Sken *
322229997Sken * Note:  Make sure the io_hdr is *always* the first element in this
323229997Sken * structure.
324229997Sken */
325229997Skenstruct ctl_taskio {
326229997Sken	struct ctl_io_hdr	io_hdr;      /* common to all I/O types */
327229997Sken	ctl_task_type		task_action; /* Target Reset, Abort, etc.  */
328229997Sken	uint32_t		tag_num;     /* tag number */
329229997Sken	ctl_tag_type		tag_type;    /* simple, ordered, etc. */
330229997Sken};
331229997Sken
332229997Skentypedef enum {
333229997Sken	CTL_PR_REG_KEY,
334229997Sken	CTL_PR_UNREG_KEY,
335229997Sken	CTL_PR_PREEMPT,
336229997Sken	CTL_PR_CLEAR,
337229997Sken	CTL_PR_RESERVE,
338229997Sken	CTL_PR_RELEASE
339229997Sken} ctl_pr_action;
340229997Sken
341229997Sken/*
342229997Sken * The PR info is specifically for sending Persistent Reserve actions
343229997Sken * to the other SC which it must also act on.
344229997Sken *
345229997Sken * Note:  Make sure the io_hdr is *always* the first element in this
346229997Sken * structure.
347229997Sken */
348229997Skenstruct ctl_pr_info {
349229997Sken	ctl_pr_action        action;
350229997Sken	uint8_t              sa_res_key[8];
351229997Sken	uint8_t              res_type;
352229997Sken	uint16_t             residx;
353229997Sken};
354229997Sken
355229997Skenstruct ctl_ha_msg_hdr {
356229997Sken	ctl_msg_type		msg_type;
357229997Sken	union ctl_io		*original_sc;
358229997Sken	union ctl_io		*serializing_sc;
359229997Sken	struct ctl_nexus	nexus;	     /* Initiator, port, target, lun */
360229997Sken	uint32_t		status;	     /* transaction status */
361229997Sken	TAILQ_ENTRY(ctl_ha_msg_hdr) links;
362229997Sken};
363229997Sken
364229997Sken#define	CTL_HA_MAX_SG_ENTRIES	16
365229997Sken
366229997Sken/*
367229997Sken * Used for CTL_MSG_APS_LOCK.
368229997Sken */
369229997Skenstruct ctl_ha_msg_aps {
370229997Sken	struct ctl_ha_msg_hdr	hdr;
371229997Sken	uint8_t			lock_flag;
372229997Sken};
373229997Sken
374229997Sken/*
375229997Sken * Used for CTL_MSG_PERS_ACTION.
376229997Sken */
377229997Skenstruct ctl_ha_msg_pr {
378229997Sken	struct ctl_ha_msg_hdr	hdr;
379229997Sken	struct ctl_pr_info	pr_info;
380229997Sken};
381229997Sken
382229997Sken/*
383229997Sken * The S/G handling here is a little different than the standard ctl_scsiio
384229997Sken * structure, because we can't pass data by reference in between controllers.
385229997Sken * The S/G list in the ctl_scsiio struct is normally passed in the
386229997Sken * kern_data_ptr field.  So kern_sg_entries here will always be non-zero,
387229997Sken * even if there is only one entry.
388229997Sken *
389229997Sken * Used for CTL_MSG_DATAMOVE.
390229997Sken */
391229997Skenstruct ctl_ha_msg_dt {
392229997Sken	struct ctl_ha_msg_hdr	hdr;
393229997Sken	ctl_io_flags		flags;  /* Only I/O flags are used here */
394229997Sken	uint32_t		sg_sequence;     /* S/G portion number  */
395229997Sken	uint8_t			sg_last;         /* last S/G batch = 1 */
396229997Sken	uint32_t		sent_sg_entries; /* previous S/G count */
397229997Sken	uint32_t		cur_sg_entries;  /* current S/G entries */
398229997Sken	uint32_t		kern_sg_entries; /* total S/G entries */
399229997Sken	uint32_t		kern_data_len;   /* Length of this S/G list */
400229997Sken	uint32_t		kern_total_len;  /* Total length of this
401229997Sken						    transaction */
402229997Sken	uint32_t		kern_data_resid; /* Length left to transfer
403229997Sken						    after this*/
404229997Sken	uint32_t		kern_rel_offset; /* Byte Offset of this
405229997Sken						    transfer */
406229997Sken	struct ctl_sg_entry	sg_list[CTL_HA_MAX_SG_ENTRIES];
407229997Sken};
408229997Sken
409229997Sken/*
410229997Sken * Used for CTL_MSG_SERIALIZE, CTL_MSG_FINISH_IO, CTL_MSG_BAD_JUJU.
411229997Sken */
412229997Skenstruct ctl_ha_msg_scsi {
413229997Sken	struct ctl_ha_msg_hdr	hdr;
414229997Sken	uint8_t			cdb[CTL_MAX_CDBLEN];	/* CDB */
415229997Sken	uint32_t		tag_num;     /* tag number */
416229997Sken	ctl_tag_type		tag_type;    /* simple, ordered, etc. */
417229997Sken	uint8_t			scsi_status; /* SCSI status byte */
418229997Sken	struct scsi_sense_data	sense_data;  /* sense data */
419229997Sken	uint8_t			sense_len;   /* Returned sense length */
420229997Sken	uint8_t			sense_residual;	/* sense residual length */
421229997Sken	uint32_t		residual;    /* data residual length */
422229997Sken	uint32_t		fetd_status; /* trans status, set by FETD,
423229997Sken						0 = good*/
424229997Sken	struct ctl_lba_len	lbalen;      /* used for stats */
425229997Sken};
426229997Sken
427229997Sken/*
428229997Sken * Used for CTL_MSG_MANAGE_TASKS.
429229997Sken */
430229997Skenstruct ctl_ha_msg_task {
431229997Sken	struct ctl_ha_msg_hdr	hdr;
432229997Sken	ctl_task_type		task_action; /* Target Reset, Abort, etc.  */
433229997Sken	uint32_t		tag_num;     /* tag number */
434229997Sken	ctl_tag_type		tag_type;    /* simple, ordered, etc. */
435229997Sken};
436229997Sken
437229997Skenunion ctl_ha_msg {
438229997Sken	struct ctl_ha_msg_hdr	hdr;
439229997Sken	struct ctl_ha_msg_task	task;
440229997Sken	struct ctl_ha_msg_scsi	scsi;
441229997Sken	struct ctl_ha_msg_dt	dt;
442229997Sken	struct ctl_ha_msg_pr	pr;
443229997Sken	struct ctl_ha_msg_aps	aps;
444229997Sken};
445229997Sken
446229997Sken
447229997Skenstruct ctl_prio {
448229997Sken	struct ctl_io_hdr  io_hdr;
449229997Sken	struct ctl_ha_msg_pr pr_msg;
450229997Sken};
451229997Sken
452229997Sken
453229997Sken
454229997Skenunion ctl_io {
455229997Sken	struct ctl_io_hdr io_hdr;	/* common to all I/O types */
456229997Sken	struct ctl_scsiio scsiio;	/* Normal SCSI commands */
457229997Sken	struct ctl_taskio taskio;	/* SCSI task management/reset */
458229997Sken	struct ctl_prio   presio;	/* update per. res info on other SC */
459229997Sken};
460229997Sken
461229997Sken#ifdef _KERNEL
462229997Sken
463229997Skenunion ctl_io *ctl_alloc_io(void *pool_ref);
464229997Skenvoid ctl_free_io(union ctl_io *io);
465229997Skenvoid ctl_zero_io(union ctl_io *io);
466229997Skenvoid ctl_copy_io(union ctl_io *src, union ctl_io *dest);
467229997Sken
468229997Sken#endif /* _KERNEL */
469229997Sken
470229997Sken#endif	/* _CTL_IO_H_ */
471229997Sken
472229997Sken/*
473229997Sken * vim: ts=8
474229997Sken */
475