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