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 */
207254759Strasz	uint32_t (*lun_map_fn)(void *arg, uint32_t lun);
208254759Strasz	void *lun_map_arg;
209229997Sken};
210229997Sken
211229997Skentypedef enum {
212229997Sken	CTL_MSG_SERIALIZE,
213229997Sken	CTL_MSG_R2R,
214229997Sken	CTL_MSG_FINISH_IO,
215229997Sken	CTL_MSG_BAD_JUJU,
216229997Sken	CTL_MSG_MANAGE_TASKS,
217229997Sken	CTL_MSG_PERS_ACTION,
218229997Sken	CTL_MSG_SYNC_FE,
219229997Sken	CTL_MSG_APS_LOCK,
220229997Sken	CTL_MSG_DATAMOVE,
221229997Sken	CTL_MSG_DATAMOVE_DONE
222229997Sken} ctl_msg_type;
223229997Sken
224229997Skenstruct ctl_scsiio;
225229997Sken
226229997Sken#define	CTL_NUM_SG_ENTRIES	9
227229997Sken
228229997Skenstruct ctl_io_hdr {
229229997Sken	uint32_t	  version;	/* interface version XXX */
230229997Sken	ctl_io_type	  io_type;	/* task I/O, SCSI I/O, etc. */
231229997Sken	ctl_msg_type	  msg_type;
232229997Sken	struct ctl_nexus  nexus;	/* Initiator, port, target, lun */
233229997Sken	uint32_t	  iid_indx;	/* the index into the iid mapping */
234229997Sken	uint32_t	  flags;	/* transaction flags */
235229997Sken	uint32_t	  status;	/* transaction status */
236229997Sken	uint32_t	  port_status;	/* trans status, set by PORT, 0 = good*/
237229997Sken	uint32_t	  timeout;	/* timeout in ms */
238229997Sken	uint32_t	  retries;	/* retry count */
239229997Sken#ifdef CTL_IO_DELAY
240229997Sken	uint8_t		  timer_bytes[CTL_TIMER_BYTES]; /* timer kludge */
241229997Sken#endif /* CTL_IO_DELAY */
242229997Sken#ifdef CTL_TIME_IO
243229997Sken	time_t		  start_time;	/* I/O start time */
244229997Sken	struct bintime	  start_bt;	/* Timer start ticks */
245229997Sken	struct bintime	  dma_start_bt;	/* DMA start ticks */
246229997Sken	struct bintime	  dma_bt;	/* DMA total ticks */
247229997Sken	uint32_t	  num_dmas;	/* Number of DMAs */
248229997Sken#endif /* CTL_TIME_IO */
249229997Sken	union ctl_io	  *original_sc;
250229997Sken	union ctl_io	  *serializing_sc;
251229997Sken	void		  *pool;	/* I/O pool */
252229997Sken	union ctl_priv	  ctl_private[CTL_NUM_PRIV];/* CTL private area */
253229997Sken	uint8_t		  port_priv[CTL_PORT_PRIV_SIZE];/* PORT private area*/
254229997Sken	struct ctl_sg_entry remote_sglist[CTL_NUM_SG_ENTRIES];
255229997Sken	struct ctl_sg_entry remote_dma_sglist[CTL_NUM_SG_ENTRIES];
256229997Sken	struct ctl_sg_entry local_sglist[CTL_NUM_SG_ENTRIES];
257229997Sken	struct ctl_sg_entry local_dma_sglist[CTL_NUM_SG_ENTRIES];
258229997Sken	STAILQ_ENTRY(ctl_io_hdr) links;	/* linked list pointer */
259229997Sken	TAILQ_ENTRY(ctl_io_hdr) ooa_links;
260229997Sken	TAILQ_ENTRY(ctl_io_hdr) blocked_links;
261229997Sken};
262229997Sken
263229997Skentypedef enum {
264229997Sken	CTL_TAG_UNTAGGED,
265229997Sken	CTL_TAG_SIMPLE,
266229997Sken	CTL_TAG_ORDERED,
267229997Sken	CTL_TAG_HEAD_OF_QUEUE,
268229997Sken	CTL_TAG_ACA
269229997Sken} ctl_tag_type;
270229997Sken
271229997Skenunion ctl_io;
272229997Sken
273229997Sken/*
274229997Sken * SCSI passthrough I/O structure for the CAM Target Layer.  Note
275229997Sken * that some of these fields are here for completeness, but they aren't
276229997Sken * used in the CTL implementation.  e.g., timeout and retries won't be
277229997Sken * used.
278229997Sken *
279229997Sken * Note:  Make sure the io_hdr is *always* the first element in this
280229997Sken * structure.
281229997Sken */
282229997Skenstruct ctl_scsiio {
283229997Sken	struct ctl_io_hdr io_hdr;	/* common to all I/O types */
284229997Sken	uint32_t   ext_sg_entries;	/* 0 = no S/G list, > 0 = num entries */
285229997Sken	uint8_t	   *ext_data_ptr;	/* data buffer or S/G list */
286229997Sken	uint32_t   ext_data_len;	/* Data transfer length */
287229997Sken	uint32_t   ext_data_filled;	/* Amount of data filled so far */
288229997Sken	uint32_t   kern_sg_entries;	/* 0 = no S/G list, > 0 = num entries */
289229997Sken	uint32_t   rem_sg_entries;	/* 0 = no S/G list, > 0 = num entries */
290229997Sken	uint8_t    *kern_data_ptr;	/* data buffer or S/G list */
291229997Sken	uint32_t   kern_data_len;	/* Length of this S/G list/buffer */
292229997Sken	uint32_t   kern_total_len;	/* Total length of this transaction */
293229997Sken	uint32_t   kern_data_resid;	/* Length left to transfer after this*/
294229997Sken	uint32_t   kern_rel_offset;	/* Byte Offset of this transfer */
295229997Sken	struct     scsi_sense_data sense_data;	/* sense data */
296229997Sken	uint8_t	   sense_len;		/* Returned sense length */
297229997Sken	uint8_t	   scsi_status;		/* SCSI status byte */
298229997Sken	uint8_t	   sense_residual;	/* sense residual length */
299229997Sken	uint32_t   residual;		/* data residual length */
300229997Sken	uint32_t   tag_num;		/* tag number */
301229997Sken	ctl_tag_type tag_type;		/* simple, ordered, head of queue,etc.*/
302229997Sken	uint8_t    cdb_len;		/* CDB length */
303229997Sken	uint8_t	   cdb[CTL_MAX_CDBLEN];	/* CDB */
304229997Sken	int	   (*be_move_done)(union ctl_io *io); /* called by fe */
305229997Sken	int        (*io_cont)(union ctl_io *io); /* to continue processing */
306229997Sken};
307229997Sken
308229997Skentypedef enum {
309229997Sken	CTL_TASK_ABORT_TASK,
310229997Sken	CTL_TASK_ABORT_TASK_SET,
311229997Sken	CTL_TASK_CLEAR_ACA,
312229997Sken	CTL_TASK_CLEAR_TASK_SET,
313229997Sken	CTL_TASK_LUN_RESET,
314229997Sken	CTL_TASK_TARGET_RESET,
315229997Sken	CTL_TASK_BUS_RESET,
316229997Sken	CTL_TASK_PORT_LOGIN,
317229997Sken	CTL_TASK_PORT_LOGOUT
318229997Sken} ctl_task_type;
319229997Sken
320229997Sken/*
321229997Sken * Task management I/O structure.  Aborts, bus resets, etc., are sent using
322229997Sken * this structure.
323229997Sken *
324229997Sken * Note:  Make sure the io_hdr is *always* the first element in this
325229997Sken * structure.
326229997Sken */
327229997Skenstruct ctl_taskio {
328229997Sken	struct ctl_io_hdr	io_hdr;      /* common to all I/O types */
329229997Sken	ctl_task_type		task_action; /* Target Reset, Abort, etc.  */
330229997Sken	uint32_t		tag_num;     /* tag number */
331229997Sken	ctl_tag_type		tag_type;    /* simple, ordered, etc. */
332229997Sken};
333229997Sken
334229997Skentypedef enum {
335229997Sken	CTL_PR_REG_KEY,
336229997Sken	CTL_PR_UNREG_KEY,
337229997Sken	CTL_PR_PREEMPT,
338229997Sken	CTL_PR_CLEAR,
339229997Sken	CTL_PR_RESERVE,
340229997Sken	CTL_PR_RELEASE
341229997Sken} ctl_pr_action;
342229997Sken
343229997Sken/*
344229997Sken * The PR info is specifically for sending Persistent Reserve actions
345229997Sken * to the other SC which it must also act on.
346229997Sken *
347229997Sken * Note:  Make sure the io_hdr is *always* the first element in this
348229997Sken * structure.
349229997Sken */
350229997Skenstruct ctl_pr_info {
351229997Sken	ctl_pr_action        action;
352229997Sken	uint8_t              sa_res_key[8];
353229997Sken	uint8_t              res_type;
354229997Sken	uint16_t             residx;
355229997Sken};
356229997Sken
357229997Skenstruct ctl_ha_msg_hdr {
358229997Sken	ctl_msg_type		msg_type;
359229997Sken	union ctl_io		*original_sc;
360229997Sken	union ctl_io		*serializing_sc;
361229997Sken	struct ctl_nexus	nexus;	     /* Initiator, port, target, lun */
362229997Sken	uint32_t		status;	     /* transaction status */
363229997Sken	TAILQ_ENTRY(ctl_ha_msg_hdr) links;
364229997Sken};
365229997Sken
366229997Sken#define	CTL_HA_MAX_SG_ENTRIES	16
367229997Sken
368229997Sken/*
369229997Sken * Used for CTL_MSG_APS_LOCK.
370229997Sken */
371229997Skenstruct ctl_ha_msg_aps {
372229997Sken	struct ctl_ha_msg_hdr	hdr;
373229997Sken	uint8_t			lock_flag;
374229997Sken};
375229997Sken
376229997Sken/*
377229997Sken * Used for CTL_MSG_PERS_ACTION.
378229997Sken */
379229997Skenstruct ctl_ha_msg_pr {
380229997Sken	struct ctl_ha_msg_hdr	hdr;
381229997Sken	struct ctl_pr_info	pr_info;
382229997Sken};
383229997Sken
384229997Sken/*
385229997Sken * The S/G handling here is a little different than the standard ctl_scsiio
386229997Sken * structure, because we can't pass data by reference in between controllers.
387229997Sken * The S/G list in the ctl_scsiio struct is normally passed in the
388229997Sken * kern_data_ptr field.  So kern_sg_entries here will always be non-zero,
389229997Sken * even if there is only one entry.
390229997Sken *
391229997Sken * Used for CTL_MSG_DATAMOVE.
392229997Sken */
393229997Skenstruct ctl_ha_msg_dt {
394229997Sken	struct ctl_ha_msg_hdr	hdr;
395229997Sken	ctl_io_flags		flags;  /* Only I/O flags are used here */
396229997Sken	uint32_t		sg_sequence;     /* S/G portion number  */
397229997Sken	uint8_t			sg_last;         /* last S/G batch = 1 */
398229997Sken	uint32_t		sent_sg_entries; /* previous S/G count */
399229997Sken	uint32_t		cur_sg_entries;  /* current S/G entries */
400229997Sken	uint32_t		kern_sg_entries; /* total S/G entries */
401229997Sken	uint32_t		kern_data_len;   /* Length of this S/G list */
402229997Sken	uint32_t		kern_total_len;  /* Total length of this
403229997Sken						    transaction */
404229997Sken	uint32_t		kern_data_resid; /* Length left to transfer
405229997Sken						    after this*/
406229997Sken	uint32_t		kern_rel_offset; /* Byte Offset of this
407229997Sken						    transfer */
408229997Sken	struct ctl_sg_entry	sg_list[CTL_HA_MAX_SG_ENTRIES];
409229997Sken};
410229997Sken
411229997Sken/*
412229997Sken * Used for CTL_MSG_SERIALIZE, CTL_MSG_FINISH_IO, CTL_MSG_BAD_JUJU.
413229997Sken */
414229997Skenstruct ctl_ha_msg_scsi {
415229997Sken	struct ctl_ha_msg_hdr	hdr;
416229997Sken	uint8_t			cdb[CTL_MAX_CDBLEN];	/* CDB */
417229997Sken	uint32_t		tag_num;     /* tag number */
418229997Sken	ctl_tag_type		tag_type;    /* simple, ordered, etc. */
419229997Sken	uint8_t			scsi_status; /* SCSI status byte */
420229997Sken	struct scsi_sense_data	sense_data;  /* sense data */
421229997Sken	uint8_t			sense_len;   /* Returned sense length */
422229997Sken	uint8_t			sense_residual;	/* sense residual length */
423229997Sken	uint32_t		residual;    /* data residual length */
424229997Sken	uint32_t		fetd_status; /* trans status, set by FETD,
425229997Sken						0 = good*/
426229997Sken	struct ctl_lba_len	lbalen;      /* used for stats */
427229997Sken};
428229997Sken
429229997Sken/*
430229997Sken * Used for CTL_MSG_MANAGE_TASKS.
431229997Sken */
432229997Skenstruct ctl_ha_msg_task {
433229997Sken	struct ctl_ha_msg_hdr	hdr;
434229997Sken	ctl_task_type		task_action; /* Target Reset, Abort, etc.  */
435229997Sken	uint32_t		tag_num;     /* tag number */
436229997Sken	ctl_tag_type		tag_type;    /* simple, ordered, etc. */
437229997Sken};
438229997Sken
439229997Skenunion ctl_ha_msg {
440229997Sken	struct ctl_ha_msg_hdr	hdr;
441229997Sken	struct ctl_ha_msg_task	task;
442229997Sken	struct ctl_ha_msg_scsi	scsi;
443229997Sken	struct ctl_ha_msg_dt	dt;
444229997Sken	struct ctl_ha_msg_pr	pr;
445229997Sken	struct ctl_ha_msg_aps	aps;
446229997Sken};
447229997Sken
448229997Sken
449229997Skenstruct ctl_prio {
450229997Sken	struct ctl_io_hdr  io_hdr;
451229997Sken	struct ctl_ha_msg_pr pr_msg;
452229997Sken};
453229997Sken
454229997Sken
455229997Sken
456229997Skenunion ctl_io {
457229997Sken	struct ctl_io_hdr io_hdr;	/* common to all I/O types */
458229997Sken	struct ctl_scsiio scsiio;	/* Normal SCSI commands */
459229997Sken	struct ctl_taskio taskio;	/* SCSI task management/reset */
460229997Sken	struct ctl_prio   presio;	/* update per. res info on other SC */
461229997Sken};
462229997Sken
463229997Sken#ifdef _KERNEL
464229997Sken
465229997Skenunion ctl_io *ctl_alloc_io(void *pool_ref);
466229997Skenvoid ctl_free_io(union ctl_io *io);
467229997Skenvoid ctl_zero_io(union ctl_io *io);
468229997Skenvoid ctl_copy_io(union ctl_io *src, union ctl_io *dest);
469229997Sken
470229997Sken#endif /* _KERNEL */
471229997Sken
472229997Sken#endif	/* _CTL_IO_H_ */
473229997Sken
474229997Sken/*
475229997Sken * vim: ts=8
476229997Sken */
477