xref: /freebsd/sys/cam/ctl/ctl_io.h (revision d485c77f203fb0f4cdc08dea5ff81631b51d8809)
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_ABORT_STATUS	= 0x00000400,	/* return TASK ABORTED status */
91 	CTL_FLAG_ABORT		= 0x00000800,	/* this I/O should be aborted */
92 	CTL_FLAG_DMA_INPROG	= 0x00001000,	/* DMA in progress */
93 	CTL_FLAG_DELAY_DONE	= 0x00004000,	/* delay injection done */
94 	CTL_FLAG_INT_COPY	= 0x00008000,	/* internal copy, no done call*/
95 	CTL_FLAG_SENT_2OTHER_SC	= 0x00010000,
96 	CTL_FLAG_FROM_OTHER_SC	= 0x00020000,
97 	CTL_FLAG_IS_WAS_ON_RTR  = 0x00040000,	/* Don't rerun cmd on failover*/
98 	CTL_FLAG_BUS_ADDR	= 0x00080000,	/* ctl_sglist contains BUS
99 						   addresses, not virtual ones*/
100 	CTL_FLAG_IO_CONT	= 0x00100000,	/* Continue I/O instead of
101 						   completing */
102 #if 0
103 	CTL_FLAG_ALREADY_DONE	= 0x00200000	/* I/O already completed */
104 #endif
105 	CTL_FLAG_NO_DATAMOVE	= 0x00400000,
106 	CTL_FLAG_DMA_QUEUED	= 0x00800000,	/* DMA queued but not started*/
107 	CTL_FLAG_STATUS_QUEUED	= 0x01000000,	/* Status queued but not sent*/
108 
109 	CTL_FLAG_FAILOVER	= 0x04000000,	/* Killed by a failover */
110 	CTL_FLAG_IO_ACTIVE	= 0x08000000,	/* I/O active on this SC */
111 	CTL_FLAG_STATUS_SENT	= 0x10000000,	/* Status sent by datamove */
112 	CTL_FLAG_SERSEQ_DONE	= 0x20000000	/* All storage I/O started */
113 } ctl_io_flags;
114 
115 struct ctl_lba_len {
116 	uint64_t lba;
117 	uint32_t len;
118 };
119 
120 struct ctl_lba_len_flags {
121 	uint64_t lba;
122 	uint32_t len;
123 	uint32_t flags;
124 #define CTL_LLF_FUA	0x04000000
125 #define CTL_LLF_DPO	0x08000000
126 #define CTL_LLF_READ	0x10000000
127 #define CTL_LLF_WRITE	0x20000000
128 #define CTL_LLF_VERIFY	0x40000000
129 #define CTL_LLF_COMPARE	0x80000000
130 };
131 
132 struct ctl_ptr_len_flags {
133 	uint8_t		*ptr;
134 	uint32_t	len;
135 	uint32_t	flags;
136 };
137 
138 union ctl_priv {
139 	uint8_t		bytes[sizeof(uint64_t) * 2];
140 	uint64_t	integer;
141 	uint64_t	integers[2];
142 	void		*ptr;
143 	void		*ptrs[2];
144 };
145 
146 /*
147  * Number of CTL private areas.
148  */
149 #define	CTL_NUM_PRIV	6
150 
151 /*
152  * Which private area are we using for a particular piece of data?
153  */
154 #define	CTL_PRIV_LUN		0	/* CTL LUN pointer goes here */
155 #define	CTL_PRIV_LBA_LEN	1	/* Decoded LBA/len for read/write*/
156 #define	CTL_PRIV_MODEPAGE	1	/* Modepage info for config write */
157 #define	CTL_PRIV_BACKEND	2	/* Reserved for block, RAIDCore */
158 #define	CTL_PRIV_BACKEND_LUN	3	/* Backend LUN pointer */
159 #define	CTL_PRIV_FRONTEND	4	/* Frontend storage */
160 #define	CTL_PRIV_FRONTEND2	5	/* Another frontend storage */
161 
162 #define CTL_LUN(io)	((io)->io_hdr.ctl_private[CTL_PRIV_LUN].ptrs[0])
163 #define CTL_SOFTC(io)	((io)->io_hdr.ctl_private[CTL_PRIV_LUN].ptrs[1])
164 #define CTL_BACKEND_LUN(io)	((io)->io_hdr.ctl_private[CTL_PRIV_BACKEND_LUN].ptrs[0])
165 #define CTL_PORT(io)	(((struct ctl_softc *)CTL_SOFTC(io))->	\
166     ctl_ports[(io)->io_hdr.nexus.targ_port])
167 
168 /*
169  * These are used only on Originating SC in XFER mode, where requests don't
170  * ever reach backends, so we can reuse backend's private storage.
171  */
172 #define CTL_RSGL(io)	((io)->io_hdr.ctl_private[CTL_PRIV_BACKEND].ptrs[0])
173 #define CTL_LSGL(io)	((io)->io_hdr.ctl_private[CTL_PRIV_BACKEND].ptrs[1])
174 #define CTL_RSGLT(io)	((struct ctl_sg_entry *)CTL_RSGL(io))
175 #define CTL_LSGLT(io)	((struct ctl_sg_entry *)CTL_LSGL(io))
176 
177 #define CTL_INVALID_PORTNAME 0xFF
178 #define CTL_UNMAPPED_IID     0xFF
179 
180 struct ctl_sg_entry {
181 	void	*addr;
182 	size_t	len;
183 };
184 
185 typedef enum {
186 	CTL_IO_NONE,
187 	CTL_IO_SCSI,
188 	CTL_IO_TASK,
189 } ctl_io_type;
190 
191 struct ctl_nexus {
192 	uint32_t initid;		/* Initiator ID */
193 	uint32_t targ_port;		/* Target port, filled in by PORT */
194 	uint32_t targ_lun;		/* Destination lun */
195 	uint32_t targ_mapped_lun;	/* Destination lun CTL-wide */
196 };
197 
198 typedef enum {
199 	CTL_MSG_SERIALIZE,
200 	CTL_MSG_R2R,
201 	CTL_MSG_FINISH_IO,
202 	CTL_MSG_BAD_JUJU,
203 	CTL_MSG_MANAGE_TASKS,
204 	CTL_MSG_PERS_ACTION,
205 	CTL_MSG_DATAMOVE,
206 	CTL_MSG_DATAMOVE_DONE,
207 	CTL_MSG_UA,			/* Set/clear UA on secondary. */
208 	CTL_MSG_PORT_SYNC,		/* Information about port. */
209 	CTL_MSG_LUN_SYNC,		/* Information about LUN. */
210 	CTL_MSG_IID_SYNC,		/* Information about initiator. */
211 	CTL_MSG_LOGIN,			/* Information about HA peer. */
212 	CTL_MSG_MODE_SYNC,		/* Mode page current content. */
213 	CTL_MSG_FAILOVER		/* Fake, never sent though the wire */
214 } ctl_msg_type;
215 
216 struct ctl_scsiio;
217 
218 struct ctl_io_hdr {
219 	uint32_t	  version;	/* interface version XXX */
220 	ctl_io_type	  io_type;	/* task I/O, SCSI I/O, etc. */
221 	ctl_msg_type	  msg_type;
222 	struct ctl_nexus  nexus;	/* Initiator, port, target, lun */
223 	uint32_t	  iid_indx;	/* the index into the iid mapping */
224 	uint32_t	  flags;	/* transaction flags */
225 	uint32_t	  status;	/* transaction status */
226 	uint32_t	  port_status;	/* trans status, set by PORT, 0 = good*/
227 	uint32_t	  timeout;	/* timeout in ms */
228 	uint32_t	  retries;	/* retry count */
229 #ifdef CTL_IO_DELAY
230 	struct callout	  delay_callout;
231 #endif /* CTL_IO_DELAY */
232 #ifdef CTL_TIME_IO
233 	time_t		  start_time;	/* I/O start time */
234 	struct bintime	  start_bt;	/* Timer start ticks */
235 	struct bintime	  dma_start_bt;	/* DMA start ticks */
236 	struct bintime	  dma_bt;	/* DMA total ticks */
237 #endif /* CTL_TIME_IO */
238 	uint32_t	  num_dmas;	/* Number of DMAs */
239 	union ctl_io	  *remote_io;	/* I/O counterpart on remote HA side */
240 	union ctl_io	  *blocker;	/* I/O blocking this one */
241 	void		  *pool;	/* I/O pool */
242 	union ctl_priv	  ctl_private[CTL_NUM_PRIV];/* CTL private area */
243 	TAILQ_HEAD(, ctl_io_hdr) blocked_queue;	/* I/Os blocked by this one */
244 	STAILQ_ENTRY(ctl_io_hdr) links;	/* linked list pointer */
245 	LIST_ENTRY(ctl_io_hdr) ooa_links;	/* ooa_queue links */
246 	TAILQ_ENTRY(ctl_io_hdr) blocked_links;	/* blocked_queue links */
247 };
248 
249 typedef enum {
250 	CTL_TAG_UNTAGGED,
251 	CTL_TAG_SIMPLE,
252 	CTL_TAG_ORDERED,
253 	CTL_TAG_HEAD_OF_QUEUE,
254 	CTL_TAG_ACA
255 } ctl_tag_type;
256 
257 union ctl_io;
258 
259 typedef void (*ctl_ref)(void *arg, int diff);
260 
261 /*
262  * SCSI passthrough I/O structure for the CAM Target Layer.  Note
263  * that some of these fields are here for completeness, but they aren't
264  * used in the CTL implementation.  e.g., timeout and retries won't be
265  * used.
266  *
267  * Note:  Make sure the io_hdr is *always* the first element in this
268  * structure.
269  */
270 struct ctl_scsiio {
271 	struct ctl_io_hdr io_hdr;	/* common to all I/O types */
272 
273 	/*
274 	 * The ext_* fields are generally intended for frontend use; CTL itself
275 	 * doesn't modify or use them.
276 	 */
277 	uint32_t   ext_sg_entries;	/* 0 = no S/G list, > 0 = num entries */
278 	uint8_t	   *ext_data_ptr;	/* data buffer or S/G list */
279 	uint32_t   ext_data_len;	/* Data transfer length */
280 	uint32_t   ext_data_filled;	/* Amount of data filled so far */
281 
282 	/*
283 	 * The number of scatter/gather entries in the list pointed to
284 	 * by kern_data_ptr.  0 means there is no list, just a data pointer.
285 	 */
286 	uint32_t   kern_sg_entries;
287 
288 	uint32_t   rem_sg_entries;	/* Unused. */
289 
290 	/*
291 	 * The data pointer or a pointer to the scatter/gather list.
292 	 */
293 	uint8_t    *kern_data_ptr;
294 
295 	/*
296 	 * Length of the data buffer or scatter/gather list.  It's also
297 	 * the length of this particular piece of the data transfer,
298 	 * ie. number of bytes expected to be transferred by the current
299 	 * invocation of frontend's datamove() callback.  It's always
300 	 * less than or equal to kern_total_len.
301 	 */
302 	uint32_t   kern_data_len;
303 
304 	/*
305 	 * Total length of data to be transferred during this particular
306 	 * SCSI command, as decoded from SCSI CDB.
307 	 */
308 	uint32_t   kern_total_len;
309 
310 	/*
311 	 * Amount of data left after the current data transfer.
312 	 */
313 	uint32_t   kern_data_resid;
314 
315 	/*
316 	 * Byte offset of this transfer, equal to the amount of data
317 	 * already transferred for this SCSI command during previous
318 	 * datamove() invocations.
319 	 */
320 	uint32_t   kern_rel_offset;
321 
322 	struct     scsi_sense_data sense_data;	/* sense data */
323 	uint8_t	   sense_len;		/* Returned sense length */
324 	uint8_t	   scsi_status;		/* SCSI status byte */
325 	uint8_t	   sense_residual;	/* Unused. */
326 	uint8_t	   priority;		/* Command priority */
327 	uint32_t   residual;		/* Unused */
328 	uint32_t   tag_num;		/* tag number */
329 	ctl_tag_type tag_type;		/* simple, ordered, head of queue,etc.*/
330 	uint8_t    cdb_len;		/* CDB length */
331 	uint8_t	   cdb[CTL_MAX_CDBLEN];	/* CDB */
332 	int	   (*be_move_done)(union ctl_io *io); /* called by fe */
333 	int        (*io_cont)(union ctl_io *io); /* to continue processing */
334 	ctl_ref	    kern_data_ref;	/* Method to reference/release data */
335 	void	   *kern_data_arg;	/* Opaque argument for kern_data_ref() */
336 };
337 
338 typedef enum {
339 	CTL_TASK_ABORT_TASK,
340 	CTL_TASK_ABORT_TASK_SET,
341 	CTL_TASK_CLEAR_ACA,
342 	CTL_TASK_CLEAR_TASK_SET,
343 	CTL_TASK_I_T_NEXUS_RESET,
344 	CTL_TASK_LUN_RESET,
345 	CTL_TASK_TARGET_RESET,
346 	CTL_TASK_BUS_RESET,
347 	CTL_TASK_PORT_LOGIN,
348 	CTL_TASK_PORT_LOGOUT,
349 	CTL_TASK_QUERY_TASK,
350 	CTL_TASK_QUERY_TASK_SET,
351 	CTL_TASK_QUERY_ASYNC_EVENT
352 } ctl_task_type;
353 
354 typedef enum {
355 	CTL_TASK_FUNCTION_COMPLETE,
356 	CTL_TASK_FUNCTION_SUCCEEDED,
357 	CTL_TASK_FUNCTION_REJECTED,
358 	CTL_TASK_LUN_DOES_NOT_EXIST,
359 	CTL_TASK_FUNCTION_NOT_SUPPORTED
360 } ctl_task_status;
361 
362 /*
363  * Task management I/O structure.  Aborts, bus resets, etc., are sent using
364  * this structure.
365  *
366  * Note:  Make sure the io_hdr is *always* the first element in this
367  * structure.
368  */
369 struct ctl_taskio {
370 	struct ctl_io_hdr	io_hdr;      /* common to all I/O types */
371 	ctl_task_type		task_action; /* Target Reset, Abort, etc.  */
372 	uint32_t		tag_num;     /* tag number */
373 	ctl_tag_type		tag_type;    /* simple, ordered, etc. */
374 	uint8_t			task_status; /* Complete, Succeeded, etc. */
375 	uint8_t			task_resp[3];/* Response information */
376 };
377 
378 /*
379  * HA link messages.
380  */
381 #define	CTL_HA_VERSION		3
382 
383 /*
384  * Used for CTL_MSG_LOGIN.
385  */
386 struct ctl_ha_msg_login {
387 	ctl_msg_type		msg_type;
388 	int			version;
389 	int			ha_mode;
390 	int			ha_id;
391 	int			max_luns;
392 	int			max_ports;
393 	int			max_init_per_port;
394 };
395 
396 typedef enum {
397 	CTL_PR_REG_KEY,
398 	CTL_PR_UNREG_KEY,
399 	CTL_PR_PREEMPT,
400 	CTL_PR_CLEAR,
401 	CTL_PR_RESERVE,
402 	CTL_PR_RELEASE
403 } ctl_pr_action;
404 
405 /*
406  * The PR info is specifically for sending Persistent Reserve actions
407  * to the other SC which it must also act on.
408  *
409  * Note:  Make sure the io_hdr is *always* the first element in this
410  * structure.
411  */
412 struct ctl_pr_info {
413 	ctl_pr_action		action;
414 	uint8_t			sa_res_key[8];
415 	uint8_t			res_type;
416 	uint32_t		residx;
417 };
418 
419 struct ctl_ha_msg_hdr {
420 	ctl_msg_type		msg_type;
421 	uint32_t		status;	     /* transaction status */
422 	union ctl_io		*original_sc;
423 	union ctl_io		*serializing_sc;
424 	struct ctl_nexus	nexus;	     /* Initiator, port, target, lun */
425 };
426 
427 #define	CTL_HA_MAX_SG_ENTRIES	16
428 #define	CTL_HA_DATAMOVE_SEGMENT	131072
429 
430 /*
431  * Used for CTL_MSG_PERS_ACTION.
432  */
433 struct ctl_ha_msg_pr {
434 	struct ctl_ha_msg_hdr	hdr;
435 	struct ctl_pr_info	pr_info;
436 };
437 
438 /*
439  * Used for CTL_MSG_UA.
440  */
441 struct ctl_ha_msg_ua {
442 	struct ctl_ha_msg_hdr	hdr;
443 	int			ua_all;
444 	int			ua_set;
445 	int			ua_type;
446 	uint8_t			ua_info[8];
447 };
448 
449 /*
450  * The S/G handling here is a little different than the standard ctl_scsiio
451  * structure, because we can't pass data by reference in between controllers.
452  * The S/G list in the ctl_scsiio struct is normally passed in the
453  * kern_data_ptr field.  So kern_sg_entries here will always be non-zero,
454  * even if there is only one entry.
455  *
456  * Used for CTL_MSG_DATAMOVE.
457  */
458 struct ctl_ha_msg_dt {
459 	struct ctl_ha_msg_hdr	hdr;
460 	ctl_io_flags		flags;  /* Only I/O flags are used here */
461 	uint32_t		sg_sequence;     /* S/G portion number  */
462 	uint8_t			sg_last;         /* last S/G batch = 1 */
463 	uint32_t		sent_sg_entries; /* previous S/G count */
464 	uint32_t		cur_sg_entries;  /* current S/G entries */
465 	uint32_t		kern_sg_entries; /* total S/G entries */
466 	uint32_t		kern_data_len;   /* Length of this S/G list */
467 	uint32_t		kern_total_len;  /* Total length of this
468 						    transaction */
469 	uint32_t		kern_data_resid; /* Length left to transfer
470 						    after this*/
471 	uint32_t		kern_rel_offset; /* Byte Offset of this
472 						    transfer */
473 	struct ctl_sg_entry	sg_list[CTL_HA_MAX_SG_ENTRIES];
474 };
475 
476 /*
477  * Used for CTL_MSG_SERIALIZE, CTL_MSG_FINISH_IO, CTL_MSG_BAD_JUJU,
478  * and CTL_MSG_DATAMOVE_DONE.
479  */
480 struct ctl_ha_msg_scsi {
481 	struct ctl_ha_msg_hdr	hdr;
482 	uint32_t		tag_num;     /* tag number */
483 	ctl_tag_type		tag_type;    /* simple, ordered, etc. */
484 	uint8_t			cdb[CTL_MAX_CDBLEN];	/* CDB */
485 	uint8_t			cdb_len;	/* CDB length */
486 	uint8_t			scsi_status; /* SCSI status byte */
487 	uint8_t			sense_len;   /* Returned sense length */
488 	uint8_t			priority;    /* Command priority */
489 	uint32_t		port_status; /* trans status, set by FETD,
490 						0 = good*/
491 	uint32_t		kern_data_resid; /* for DATAMOVE_DONE */
492 	struct scsi_sense_data	sense_data;  /* sense data */
493 };
494 
495 /*
496  * Used for CTL_MSG_MANAGE_TASKS.
497  */
498 struct ctl_ha_msg_task {
499 	struct ctl_ha_msg_hdr	hdr;
500 	ctl_task_type		task_action; /* Target Reset, Abort, etc.  */
501 	uint32_t		tag_num;     /* tag number */
502 	ctl_tag_type		tag_type;    /* simple, ordered, etc. */
503 };
504 
505 /*
506  * Used for CTL_MSG_PORT_SYNC.
507  */
508 struct ctl_ha_msg_port {
509 	struct ctl_ha_msg_hdr	hdr;
510 	int			port_type;
511 	int			physical_port;
512 	int			virtual_port;
513 	int			status;
514 	int			name_len;
515 	int			lun_map_len;
516 	int			port_devid_len;
517 	int			target_devid_len;
518 	int			init_devid_len;
519 	uint8_t			data[];
520 };
521 
522 /*
523  * Used for CTL_MSG_LUN_SYNC.
524  */
525 struct ctl_ha_msg_lun {
526 	struct ctl_ha_msg_hdr	hdr;
527 	int			flags;
528 	unsigned int		pr_generation;
529 	uint32_t		pr_res_idx;
530 	uint8_t			pr_res_type;
531 	int			lun_devid_len;
532 	int			pr_key_count;
533 	uint8_t			data[];
534 };
535 
536 struct ctl_ha_msg_lun_pr_key {
537 	uint32_t		pr_iid;
538 	uint64_t		pr_key;
539 };
540 
541 /*
542  * Used for CTL_MSG_IID_SYNC.
543  */
544 struct ctl_ha_msg_iid {
545 	struct ctl_ha_msg_hdr	hdr;
546 	int			in_use;
547 	int			name_len;
548 	uint64_t		wwpn;
549 	uint8_t			data[];
550 };
551 
552 /*
553  * Used for CTL_MSG_MODE_SYNC.
554  */
555 struct ctl_ha_msg_mode {
556 	struct ctl_ha_msg_hdr	hdr;
557 	uint8_t			page_code;
558 	uint8_t			subpage;
559 	uint16_t		page_len;
560 	uint8_t			data[];
561 };
562 
563 union ctl_ha_msg {
564 	struct ctl_ha_msg_hdr	hdr;
565 	struct ctl_ha_msg_task	task;
566 	struct ctl_ha_msg_scsi	scsi;
567 	struct ctl_ha_msg_dt	dt;
568 	struct ctl_ha_msg_pr	pr;
569 	struct ctl_ha_msg_ua	ua;
570 	struct ctl_ha_msg_port	port;
571 	struct ctl_ha_msg_lun	lun;
572 	struct ctl_ha_msg_iid	iid;
573 	struct ctl_ha_msg_login	login;
574 	struct ctl_ha_msg_mode	mode;
575 };
576 
577 struct ctl_prio {
578 	struct ctl_io_hdr	io_hdr;
579 	struct ctl_ha_msg_pr	pr_msg;
580 };
581 
582 union ctl_io {
583 	struct ctl_io_hdr	io_hdr;	/* common to all I/O types */
584 	struct ctl_scsiio	scsiio;	/* Normal SCSI commands */
585 	struct ctl_taskio	taskio;	/* SCSI task management/reset */
586 	struct ctl_prio		presio;	/* update per. res info on other SC */
587 };
588 
589 #ifdef _KERNEL
590 
591 union ctl_io *ctl_alloc_io(void *pool_ref);
592 union ctl_io *ctl_alloc_io_nowait(void *pool_ref);
593 void ctl_free_io(union ctl_io *io);
594 void ctl_zero_io(union ctl_io *io);
595 
596 #endif /* _KERNEL */
597 
598 #endif	/* _CTL_IO_H_ */
599 
600 /*
601  * vim: ts=8
602  */
603