xref: /freebsd/sys/cam/ctl/ctl_io.h (revision f5147e312f43a9050468de539aeafa072caa1a60)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2003 Silicon Graphics International Corp.
5  * Copyright (c) 2014-2015 Alexander Motin <mav@FreeBSD.org>
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions, and the following disclaimer,
13  *    without modification.
14  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
15  *    substantially similar to the "NO WARRANTY" disclaimer below
16  *    ("Disclaimer") and any redistribution must be conditioned upon
17  *    including a substantially similar Disclaimer requirement for further
18  *    binary redistribution.
19  *
20  * NO WARRANTY
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGES.
32  *
33  * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_io.h#5 $
34  * $FreeBSD$
35  */
36 /*
37  * CAM Target Layer data movement structures/interface.
38  *
39  * Author: Ken Merry <ken@FreeBSD.org>
40  */
41 
42 #ifndef	_CTL_IO_H_
43 #define	_CTL_IO_H_
44 
45 #define	CTL_MAX_CDBLEN	32
46 /*
47  * Uncomment this next line to enable printing out times for I/Os
48  * that take longer than CTL_TIME_IO_SECS seconds to get to the datamove
49  * and/or done stage.
50  */
51 #define	CTL_TIME_IO
52 #ifdef  CTL_TIME_IO
53 #define	CTL_TIME_IO_DEFAULT_SECS	90
54 #endif
55 
56 /*
57  * Uncomment this next line to enable the CTL I/O delay feature.  You
58  * can delay I/O at two different points -- datamove and done.  This is
59  * useful for diagnosing abort conditions (for hosts that send an abort on a
60  * timeout), and for determining how long a host's timeout is.
61  */
62 //#define	CTL_IO_DELAY
63 
64 typedef enum {
65 	CTL_STATUS_NONE,	/* No status */
66 	CTL_SUCCESS,		/* Transaction completed successfully */
67 	CTL_CMD_TIMEOUT,	/* Command timed out, shouldn't happen here */
68 	CTL_SEL_TIMEOUT,	/* Selection timeout, shouldn't happen here */
69 	CTL_ERROR,		/* General CTL error XXX expand on this? */
70 	CTL_SCSI_ERROR,		/* SCSI error, look at status byte/sense data */
71 	CTL_CMD_ABORTED,	/* Command aborted, don't return status */
72 	CTL_STATUS_MASK = 0xfff,/* Mask off any status flags */
73 	CTL_AUTOSENSE = 0x1000	/* Autosense performed */
74 } ctl_io_status;
75 
76 /*
77  * WARNING:  Keep the data in/out/none flags where they are.  They're used
78  * in conjunction with ctl_cmd_flags.  See comment above ctl_cmd_flags
79  * definition in ctl_private.h.
80  */
81 typedef enum {
82 	CTL_FLAG_NONE		= 0x00000000,	/* no flags */
83 	CTL_FLAG_DATA_IN	= 0x00000001,	/* DATA IN */
84 	CTL_FLAG_DATA_OUT	= 0x00000002,	/* DATA OUT */
85 	CTL_FLAG_DATA_NONE	= 0x00000003,	/* no data */
86 	CTL_FLAG_DATA_MASK	= 0x00000003,
87 	CTL_FLAG_DO_AUTOSENSE	= 0x00000020,	/* grab sense info */
88 	CTL_FLAG_USER_REQ	= 0x00000040,	/* request came from userland */
89 	CTL_FLAG_ALLOCATED	= 0x00000100,	/* data space allocated */
90 	CTL_FLAG_BLOCKED	= 0x00000200,	/* on the blocked queue */
91 	CTL_FLAG_ABORT_STATUS	= 0x00000400,	/* return TASK ABORTED status */
92 	CTL_FLAG_ABORT		= 0x00000800,	/* this I/O should be aborted */
93 	CTL_FLAG_DMA_INPROG	= 0x00001000,	/* DMA in progress */
94 	CTL_FLAG_DELAY_DONE	= 0x00004000,	/* delay injection done */
95 	CTL_FLAG_INT_COPY	= 0x00008000,	/* internal copy, no done call*/
96 	CTL_FLAG_SENT_2OTHER_SC	= 0x00010000,
97 	CTL_FLAG_FROM_OTHER_SC	= 0x00020000,
98 	CTL_FLAG_IS_WAS_ON_RTR  = 0x00040000,	/* Don't rerun cmd on failover*/
99 	CTL_FLAG_BUS_ADDR	= 0x00080000,	/* ctl_sglist contains BUS
100 						   addresses, not virtual ones*/
101 	CTL_FLAG_IO_CONT	= 0x00100000,	/* Continue I/O instead of
102 						   completing */
103 #if 0
104 	CTL_FLAG_ALREADY_DONE	= 0x00200000	/* I/O already completed */
105 #endif
106 	CTL_FLAG_NO_DATAMOVE	= 0x00400000,
107 	CTL_FLAG_DMA_QUEUED	= 0x00800000,	/* DMA queued but not started*/
108 	CTL_FLAG_STATUS_QUEUED	= 0x01000000,	/* Status queued but not sent*/
109 
110 	CTL_FLAG_FAILOVER	= 0x04000000,	/* Killed by a failover */
111 	CTL_FLAG_IO_ACTIVE	= 0x08000000,	/* I/O active on this SC */
112 	CTL_FLAG_STATUS_SENT	= 0x10000000,	/* Status sent by datamove */
113 	CTL_FLAG_SERSEQ_DONE	= 0x20000000	/* All storage I/O started */
114 } ctl_io_flags;
115 
116 
117 struct ctl_lba_len {
118 	uint64_t lba;
119 	uint32_t len;
120 };
121 
122 struct ctl_lba_len_flags {
123 	uint64_t lba;
124 	uint32_t len;
125 	uint32_t flags;
126 #define CTL_LLF_FUA	0x04000000
127 #define CTL_LLF_DPO	0x08000000
128 #define CTL_LLF_READ	0x10000000
129 #define CTL_LLF_WRITE	0x20000000
130 #define CTL_LLF_VERIFY	0x40000000
131 #define CTL_LLF_COMPARE	0x80000000
132 };
133 
134 struct ctl_ptr_len_flags {
135 	uint8_t		*ptr;
136 	uint32_t	len;
137 	uint32_t	flags;
138 };
139 
140 union ctl_priv {
141 	uint8_t		bytes[sizeof(uint64_t) * 2];
142 	uint64_t	integer;
143 	uint64_t	integers[2];
144 	void		*ptr;
145 	void		*ptrs[2];
146 };
147 
148 /*
149  * Number of CTL private areas.
150  */
151 #define	CTL_NUM_PRIV	6
152 
153 /*
154  * Which private area are we using for a particular piece of data?
155  */
156 #define	CTL_PRIV_LUN		0	/* CTL LUN pointer goes here */
157 #define	CTL_PRIV_LBA_LEN	1	/* Decoded LBA/len for read/write*/
158 #define	CTL_PRIV_MODEPAGE	1	/* Modepage info for config write */
159 #define	CTL_PRIV_BACKEND	2	/* Reserved for block, RAIDCore */
160 #define	CTL_PRIV_BACKEND_LUN	3	/* Backend LUN pointer */
161 #define	CTL_PRIV_FRONTEND	4	/* Frontend storage */
162 #define	CTL_PRIV_FRONTEND2	5	/* Another frontend storage */
163 
164 #define CTL_LUN(io)	((io)->io_hdr.ctl_private[CTL_PRIV_LUN].ptrs[0])
165 #define CTL_SOFTC(io)	((io)->io_hdr.ctl_private[CTL_PRIV_LUN].ptrs[1])
166 #define CTL_BACKEND_LUN(io)	((io)->io_hdr.ctl_private[CTL_PRIV_BACKEND_LUN].ptrs[0])
167 #define CTL_PORT(io)	(((struct ctl_softc *)CTL_SOFTC(io))->	\
168     ctl_ports[(io)->io_hdr.nexus.targ_port])
169 
170 #define CTL_INVALID_PORTNAME 0xFF
171 #define CTL_UNMAPPED_IID     0xFF
172 
173 struct ctl_sg_entry {
174 	void	*addr;
175 	size_t	len;
176 };
177 
178 typedef enum {
179 	CTL_IO_NONE,
180 	CTL_IO_SCSI,
181 	CTL_IO_TASK,
182 } ctl_io_type;
183 
184 struct ctl_nexus {
185 	uint32_t initid;		/* Initiator ID */
186 	uint32_t targ_port;		/* Target port, filled in by PORT */
187 	uint32_t targ_lun;		/* Destination lun */
188 	uint32_t targ_mapped_lun;	/* Destination lun CTL-wide */
189 };
190 
191 typedef enum {
192 	CTL_MSG_SERIALIZE,
193 	CTL_MSG_R2R,
194 	CTL_MSG_FINISH_IO,
195 	CTL_MSG_BAD_JUJU,
196 	CTL_MSG_MANAGE_TASKS,
197 	CTL_MSG_PERS_ACTION,
198 	CTL_MSG_DATAMOVE,
199 	CTL_MSG_DATAMOVE_DONE,
200 	CTL_MSG_UA,			/* Set/clear UA on secondary. */
201 	CTL_MSG_PORT_SYNC,		/* Information about port. */
202 	CTL_MSG_LUN_SYNC,		/* Information about LUN. */
203 	CTL_MSG_IID_SYNC,		/* Information about initiator. */
204 	CTL_MSG_LOGIN,			/* Information about HA peer. */
205 	CTL_MSG_MODE_SYNC,		/* Mode page current content. */
206 	CTL_MSG_FAILOVER		/* Fake, never sent though the wire */
207 } ctl_msg_type;
208 
209 struct ctl_scsiio;
210 
211 struct ctl_io_hdr {
212 	uint32_t	  version;	/* interface version XXX */
213 	ctl_io_type	  io_type;	/* task I/O, SCSI I/O, etc. */
214 	ctl_msg_type	  msg_type;
215 	struct ctl_nexus  nexus;	/* Initiator, port, target, lun */
216 	uint32_t	  iid_indx;	/* the index into the iid mapping */
217 	uint32_t	  flags;	/* transaction flags */
218 	uint32_t	  status;	/* transaction status */
219 	uint32_t	  port_status;	/* trans status, set by PORT, 0 = good*/
220 	uint32_t	  timeout;	/* timeout in ms */
221 	uint32_t	  retries;	/* retry count */
222 #ifdef CTL_IO_DELAY
223 	struct callout	  delay_callout;
224 #endif /* CTL_IO_DELAY */
225 #ifdef CTL_TIME_IO
226 	time_t		  start_time;	/* I/O start time */
227 	struct bintime	  start_bt;	/* Timer start ticks */
228 	struct bintime	  dma_start_bt;	/* DMA start ticks */
229 	struct bintime	  dma_bt;	/* DMA total ticks */
230 #endif /* CTL_TIME_IO */
231 	uint32_t	  num_dmas;	/* Number of DMAs */
232 	union ctl_io	  *original_sc;
233 	union ctl_io	  *serializing_sc;
234 	void		  *pool;	/* I/O pool */
235 	union ctl_priv	  ctl_private[CTL_NUM_PRIV];/* CTL private area */
236 	struct ctl_sg_entry *remote_sglist;
237 	struct ctl_sg_entry *local_sglist;
238 	STAILQ_ENTRY(ctl_io_hdr) links;	/* linked list pointer */
239 	TAILQ_ENTRY(ctl_io_hdr) ooa_links;
240 	TAILQ_ENTRY(ctl_io_hdr) blocked_links;
241 };
242 
243 typedef enum {
244 	CTL_TAG_UNTAGGED,
245 	CTL_TAG_SIMPLE,
246 	CTL_TAG_ORDERED,
247 	CTL_TAG_HEAD_OF_QUEUE,
248 	CTL_TAG_ACA
249 } ctl_tag_type;
250 
251 union ctl_io;
252 
253 /*
254  * SCSI passthrough I/O structure for the CAM Target Layer.  Note
255  * that some of these fields are here for completeness, but they aren't
256  * used in the CTL implementation.  e.g., timeout and retries won't be
257  * used.
258  *
259  * Note:  Make sure the io_hdr is *always* the first element in this
260  * structure.
261  */
262 struct ctl_scsiio {
263 	struct ctl_io_hdr io_hdr;	/* common to all I/O types */
264 
265 	/*
266 	 * The ext_* fields are generally intended for frontend use; CTL itself
267 	 * doesn't modify or use them.
268 	 */
269 	uint32_t   ext_sg_entries;	/* 0 = no S/G list, > 0 = num entries */
270 	uint8_t	   *ext_data_ptr;	/* data buffer or S/G list */
271 	uint32_t   ext_data_len;	/* Data transfer length */
272 	uint32_t   ext_data_filled;	/* Amount of data filled so far */
273 
274 	/*
275 	 * The number of scatter/gather entries in the list pointed to
276 	 * by kern_data_ptr.  0 means there is no list, just a data pointer.
277 	 */
278 	uint32_t   kern_sg_entries;
279 
280 	uint32_t   rem_sg_entries;	/* Unused. */
281 
282 	/*
283 	 * The data pointer or a pointer to the scatter/gather list.
284 	 */
285 	uint8_t    *kern_data_ptr;
286 
287 	/*
288 	 * Length of the data buffer or scatter/gather list.  It's also
289 	 * the length of this particular piece of the data transfer,
290 	 * ie. number of bytes expected to be transferred by the current
291 	 * invocation of frontend's datamove() callback.  It's always
292 	 * less than or equal to kern_total_len.
293 	 */
294 	uint32_t   kern_data_len;
295 
296 	/*
297 	 * Total length of data to be transferred during this particular
298 	 * SCSI command, as decoded from SCSI CDB.
299 	 */
300 	uint32_t   kern_total_len;
301 
302 	/*
303 	 * Amount of data left after the current data transfer.
304 	 */
305 	uint32_t   kern_data_resid;
306 
307 	/*
308 	 * Byte offset of this transfer, equal to the amount of data
309 	 * already transferred for this SCSI command during previous
310 	 * datamove() invocations.
311 	 */
312 	uint32_t   kern_rel_offset;
313 
314 	struct     scsi_sense_data sense_data;	/* sense data */
315 	uint8_t	   sense_len;		/* Returned sense length */
316 	uint8_t	   scsi_status;		/* SCSI status byte */
317 	uint8_t	   sense_residual;	/* Unused. */
318 	uint32_t   residual;		/* Unused */
319 	uint32_t   tag_num;		/* tag number */
320 	ctl_tag_type tag_type;		/* simple, ordered, head of queue,etc.*/
321 	uint8_t    cdb_len;		/* CDB length */
322 	uint8_t	   cdb[CTL_MAX_CDBLEN];	/* CDB */
323 	int	   (*be_move_done)(union ctl_io *io); /* called by fe */
324 	int        (*io_cont)(union ctl_io *io); /* to continue processing */
325 };
326 
327 typedef enum {
328 	CTL_TASK_ABORT_TASK,
329 	CTL_TASK_ABORT_TASK_SET,
330 	CTL_TASK_CLEAR_ACA,
331 	CTL_TASK_CLEAR_TASK_SET,
332 	CTL_TASK_I_T_NEXUS_RESET,
333 	CTL_TASK_LUN_RESET,
334 	CTL_TASK_TARGET_RESET,
335 	CTL_TASK_BUS_RESET,
336 	CTL_TASK_PORT_LOGIN,
337 	CTL_TASK_PORT_LOGOUT,
338 	CTL_TASK_QUERY_TASK,
339 	CTL_TASK_QUERY_TASK_SET,
340 	CTL_TASK_QUERY_ASYNC_EVENT
341 } ctl_task_type;
342 
343 typedef enum {
344 	CTL_TASK_FUNCTION_COMPLETE,
345 	CTL_TASK_FUNCTION_SUCCEEDED,
346 	CTL_TASK_FUNCTION_REJECTED,
347 	CTL_TASK_LUN_DOES_NOT_EXIST,
348 	CTL_TASK_FUNCTION_NOT_SUPPORTED
349 } ctl_task_status;
350 
351 /*
352  * Task management I/O structure.  Aborts, bus resets, etc., are sent using
353  * this structure.
354  *
355  * Note:  Make sure the io_hdr is *always* the first element in this
356  * structure.
357  */
358 struct ctl_taskio {
359 	struct ctl_io_hdr	io_hdr;      /* common to all I/O types */
360 	ctl_task_type		task_action; /* Target Reset, Abort, etc.  */
361 	uint32_t		tag_num;     /* tag number */
362 	ctl_tag_type		tag_type;    /* simple, ordered, etc. */
363 	uint8_t			task_status; /* Complete, Succeeded, etc. */
364 	uint8_t			task_resp[3];/* Response information */
365 };
366 
367 
368 /*
369  * HA link messages.
370  */
371 #define	CTL_HA_VERSION		3
372 
373 /*
374  * Used for CTL_MSG_LOGIN.
375  */
376 struct ctl_ha_msg_login {
377 	ctl_msg_type		msg_type;
378 	int			version;
379 	int			ha_mode;
380 	int			ha_id;
381 	int			max_luns;
382 	int			max_ports;
383 	int			max_init_per_port;
384 };
385 
386 typedef enum {
387 	CTL_PR_REG_KEY,
388 	CTL_PR_UNREG_KEY,
389 	CTL_PR_PREEMPT,
390 	CTL_PR_CLEAR,
391 	CTL_PR_RESERVE,
392 	CTL_PR_RELEASE
393 } ctl_pr_action;
394 
395 /*
396  * The PR info is specifically for sending Persistent Reserve actions
397  * to the other SC which it must also act on.
398  *
399  * Note:  Make sure the io_hdr is *always* the first element in this
400  * structure.
401  */
402 struct ctl_pr_info {
403 	ctl_pr_action		action;
404 	uint8_t			sa_res_key[8];
405 	uint8_t			res_type;
406 	uint32_t		residx;
407 };
408 
409 struct ctl_ha_msg_hdr {
410 	ctl_msg_type		msg_type;
411 	uint32_t		status;	     /* transaction status */
412 	union ctl_io		*original_sc;
413 	union ctl_io		*serializing_sc;
414 	struct ctl_nexus	nexus;	     /* Initiator, port, target, lun */
415 };
416 
417 #define	CTL_HA_MAX_SG_ENTRIES	16
418 #define	CTL_HA_DATAMOVE_SEGMENT	131072
419 
420 /*
421  * Used for CTL_MSG_PERS_ACTION.
422  */
423 struct ctl_ha_msg_pr {
424 	struct ctl_ha_msg_hdr	hdr;
425 	struct ctl_pr_info	pr_info;
426 };
427 
428 /*
429  * Used for CTL_MSG_UA.
430  */
431 struct ctl_ha_msg_ua {
432 	struct ctl_ha_msg_hdr	hdr;
433 	int			ua_all;
434 	int			ua_set;
435 	int			ua_type;
436 	uint8_t			ua_info[8];
437 };
438 
439 /*
440  * The S/G handling here is a little different than the standard ctl_scsiio
441  * structure, because we can't pass data by reference in between controllers.
442  * The S/G list in the ctl_scsiio struct is normally passed in the
443  * kern_data_ptr field.  So kern_sg_entries here will always be non-zero,
444  * even if there is only one entry.
445  *
446  * Used for CTL_MSG_DATAMOVE.
447  */
448 struct ctl_ha_msg_dt {
449 	struct ctl_ha_msg_hdr	hdr;
450 	ctl_io_flags		flags;  /* Only I/O flags are used here */
451 	uint32_t		sg_sequence;     /* S/G portion number  */
452 	uint8_t			sg_last;         /* last S/G batch = 1 */
453 	uint32_t		sent_sg_entries; /* previous S/G count */
454 	uint32_t		cur_sg_entries;  /* current S/G entries */
455 	uint32_t		kern_sg_entries; /* total S/G entries */
456 	uint32_t		kern_data_len;   /* Length of this S/G list */
457 	uint32_t		kern_total_len;  /* Total length of this
458 						    transaction */
459 	uint32_t		kern_data_resid; /* Length left to transfer
460 						    after this*/
461 	uint32_t		kern_rel_offset; /* Byte Offset of this
462 						    transfer */
463 	struct ctl_sg_entry	sg_list[CTL_HA_MAX_SG_ENTRIES];
464 };
465 
466 /*
467  * Used for CTL_MSG_SERIALIZE, CTL_MSG_FINISH_IO, CTL_MSG_BAD_JUJU,
468  * and CTL_MSG_DATAMOVE_DONE.
469  */
470 struct ctl_ha_msg_scsi {
471 	struct ctl_ha_msg_hdr	hdr;
472 	uint32_t		tag_num;     /* tag number */
473 	ctl_tag_type		tag_type;    /* simple, ordered, etc. */
474 	uint8_t			cdb[CTL_MAX_CDBLEN];	/* CDB */
475 	uint8_t			cdb_len;	/* CDB length */
476 	uint8_t			scsi_status; /* SCSI status byte */
477 	uint8_t			sense_len;   /* Returned sense length */
478 	uint32_t		port_status; /* trans status, set by FETD,
479 						0 = good*/
480 	uint32_t		kern_data_resid; /* for DATAMOVE_DONE */
481 	struct scsi_sense_data	sense_data;  /* sense data */
482 };
483 
484 /*
485  * Used for CTL_MSG_MANAGE_TASKS.
486  */
487 struct ctl_ha_msg_task {
488 	struct ctl_ha_msg_hdr	hdr;
489 	ctl_task_type		task_action; /* Target Reset, Abort, etc.  */
490 	uint32_t		tag_num;     /* tag number */
491 	ctl_tag_type		tag_type;    /* simple, ordered, etc. */
492 };
493 
494 /*
495  * Used for CTL_MSG_PORT_SYNC.
496  */
497 struct ctl_ha_msg_port {
498 	struct ctl_ha_msg_hdr	hdr;
499 	int			port_type;
500 	int			physical_port;
501 	int			virtual_port;
502 	int			status;
503 	int			name_len;
504 	int			lun_map_len;
505 	int			port_devid_len;
506 	int			target_devid_len;
507 	int			init_devid_len;
508 	uint8_t			data[];
509 };
510 
511 /*
512  * Used for CTL_MSG_LUN_SYNC.
513  */
514 struct ctl_ha_msg_lun {
515 	struct ctl_ha_msg_hdr	hdr;
516 	int			flags;
517 	unsigned int		pr_generation;
518 	uint32_t		pr_res_idx;
519 	uint8_t			pr_res_type;
520 	int			lun_devid_len;
521 	int			pr_key_count;
522 	uint8_t			data[];
523 };
524 
525 struct ctl_ha_msg_lun_pr_key {
526 	uint32_t		pr_iid;
527 	uint64_t		pr_key;
528 };
529 
530 /*
531  * Used for CTL_MSG_IID_SYNC.
532  */
533 struct ctl_ha_msg_iid {
534 	struct ctl_ha_msg_hdr	hdr;
535 	int			in_use;
536 	int			name_len;
537 	uint64_t		wwpn;
538 	uint8_t			data[];
539 };
540 
541 /*
542  * Used for CTL_MSG_MODE_SYNC.
543  */
544 struct ctl_ha_msg_mode {
545 	struct ctl_ha_msg_hdr	hdr;
546 	uint8_t			page_code;
547 	uint8_t			subpage;
548 	uint16_t		page_len;
549 	uint8_t			data[];
550 };
551 
552 union ctl_ha_msg {
553 	struct ctl_ha_msg_hdr	hdr;
554 	struct ctl_ha_msg_task	task;
555 	struct ctl_ha_msg_scsi	scsi;
556 	struct ctl_ha_msg_dt	dt;
557 	struct ctl_ha_msg_pr	pr;
558 	struct ctl_ha_msg_ua	ua;
559 	struct ctl_ha_msg_port	port;
560 	struct ctl_ha_msg_lun	lun;
561 	struct ctl_ha_msg_iid	iid;
562 	struct ctl_ha_msg_login	login;
563 	struct ctl_ha_msg_mode	mode;
564 };
565 
566 struct ctl_prio {
567 	struct ctl_io_hdr	io_hdr;
568 	struct ctl_ha_msg_pr	pr_msg;
569 };
570 
571 union ctl_io {
572 	struct ctl_io_hdr	io_hdr;	/* common to all I/O types */
573 	struct ctl_scsiio	scsiio;	/* Normal SCSI commands */
574 	struct ctl_taskio	taskio;	/* SCSI task management/reset */
575 	struct ctl_prio		presio;	/* update per. res info on other SC */
576 };
577 
578 #ifdef _KERNEL
579 
580 union ctl_io *ctl_alloc_io(void *pool_ref);
581 union ctl_io *ctl_alloc_io_nowait(void *pool_ref);
582 void ctl_free_io(union ctl_io *io);
583 void ctl_zero_io(union ctl_io *io);
584 
585 #endif /* _KERNEL */
586 
587 #endif	/* _CTL_IO_H_ */
588 
589 /*
590  * vim: ts=8
591  */
592