1/*-
2 * Copyright (c) 2003 Silicon Graphics International Corp.
3 * Copyright (c) 2011 Spectra Logic Corporation
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions, and the following disclaimer,
11 *    without modification.
12 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
13 *    substantially similar to the "NO WARRANTY" disclaimer below
14 *    ("Disclaimer") and any redistribution must be conditioned upon
15 *    including a substantially similar Disclaimer requirement for further
16 *    binary redistribution.
17 *
18 * NO WARRANTY
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
28 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGES.
30 *
31 * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_ioctl.h#4 $
32 * $FreeBSD: releng/10.3/sys/cam/ctl/ctl_ioctl.h 288805 2015-10-05 11:25:48Z mav $
33 */
34/*
35 * CAM Target Layer ioctl interface.
36 *
37 * Author: Ken Merry <ken@FreeBSD.org>
38 */
39
40#ifndef	_CTL_IOCTL_H_
41#define	_CTL_IOCTL_H_
42
43#ifdef ICL_KERNEL_PROXY
44#include <sys/socket.h>
45#endif
46
47#include <sys/ioccom.h>
48
49#define	CTL_DEFAULT_DEV		"/dev/cam/ctl"
50/*
51 * Maximum number of targets we support.
52 */
53#define	CTL_MAX_TARGETS		1
54
55/*
56 * Maximum target ID we support.
57 */
58#define	CTL_MAX_TARGID		15
59
60/*
61 * Maximum number of LUNs we support at the moment.  MUST be a power of 2.
62 */
63#define	CTL_MAX_LUNS		1024
64
65/*
66 * Maximum number of initiators per port.
67 */
68#define	CTL_MAX_INIT_PER_PORT	2048
69
70/*
71 * Maximum number of ports registered at one time.
72 */
73#define	CTL_MAX_PORTS		256
74
75/*
76 * Maximum number of initiators we support.
77 */
78#define	CTL_MAX_INITIATORS	(CTL_MAX_INIT_PER_PORT * CTL_MAX_PORTS)
79
80/* Hopefully this won't conflict with new misc devices that pop up */
81#define	CTL_MINOR	225
82
83typedef enum {
84	CTL_DELAY_TYPE_NONE,
85	CTL_DELAY_TYPE_CONT,
86	CTL_DELAY_TYPE_ONESHOT
87} ctl_delay_type;
88
89typedef enum {
90	CTL_DELAY_LOC_NONE,
91	CTL_DELAY_LOC_DATAMOVE,
92	CTL_DELAY_LOC_DONE,
93} ctl_delay_location;
94
95typedef enum {
96	CTL_DELAY_STATUS_NONE,
97	CTL_DELAY_STATUS_OK,
98	CTL_DELAY_STATUS_INVALID_LUN,
99	CTL_DELAY_STATUS_INVALID_TYPE,
100	CTL_DELAY_STATUS_INVALID_LOC,
101	CTL_DELAY_STATUS_NOT_IMPLEMENTED
102} ctl_delay_status;
103
104struct ctl_io_delay_info {
105	uint32_t		lun_id;
106	ctl_delay_type		delay_type;
107	ctl_delay_location	delay_loc;
108	uint32_t		delay_secs;
109	ctl_delay_status	status;
110};
111
112typedef enum {
113	CTL_STATS_NO_IO,
114	CTL_STATS_READ,
115	CTL_STATS_WRITE
116} ctl_stat_types;
117#define	CTL_STATS_NUM_TYPES	3
118
119typedef enum {
120	CTL_LUN_STATS_NO_BLOCKSIZE	= 0x01
121} ctl_lun_stats_flags;
122
123struct ctl_lun_io_port_stats {
124	uint32_t			targ_port;
125	uint64_t			bytes[CTL_STATS_NUM_TYPES];
126	uint64_t			operations[CTL_STATS_NUM_TYPES];
127	struct bintime			time[CTL_STATS_NUM_TYPES];
128	uint64_t			num_dmas[CTL_STATS_NUM_TYPES];
129	struct bintime			dma_time[CTL_STATS_NUM_TYPES];
130};
131
132struct ctl_lun_io_stats {
133	uint8_t				device_type;
134	uint64_t			lun_number;
135	uint32_t			blocksize;
136	ctl_lun_stats_flags		flags;
137	struct ctl_lun_io_port_stats	ports[CTL_MAX_PORTS];
138};
139
140typedef enum {
141	CTL_SS_OK,
142	CTL_SS_NEED_MORE_SPACE,
143	CTL_SS_ERROR
144} ctl_stats_status;
145
146typedef enum {
147	CTL_STATS_FLAG_NONE		= 0x00,
148	CTL_STATS_FLAG_TIME_VALID	= 0x01
149} ctl_stats_flags;
150
151struct ctl_stats {
152	int			alloc_len;	/* passed to kernel */
153	struct ctl_lun_io_stats	*lun_stats;	/* passed to/from kernel */
154	int			fill_len;	/* passed to userland */
155	int			num_luns;	/* passed to userland */
156	ctl_stats_status	status;		/* passed to userland */
157	ctl_stats_flags		flags;		/* passed to userland */
158	struct timespec		timestamp;	/* passed to userland */
159};
160
161/*
162 * The types of errors that can be injected:
163 *
164 * NONE:	No error specified.
165 * ABORTED:	SSD_KEY_ABORTED_COMMAND, 0x45, 0x00
166 * MEDIUM_ERR:	Medium error, different asc/ascq depending on read/write.
167 * UA:		Unit attention.
168 * CUSTOM:	User specifies the sense data.
169 * TYPE:	Mask to use with error types.
170 *
171 * Flags that affect injection behavior:
172 * CONTINUOUS:	This error will stay around until explicitly cleared.
173 * DESCRIPTOR:	Use descriptor sense instead of fixed sense.
174 */
175typedef enum {
176	CTL_LUN_INJ_NONE		= 0x000,
177	CTL_LUN_INJ_ABORTED		= 0x001,
178	CTL_LUN_INJ_MEDIUM_ERR		= 0x002,
179	CTL_LUN_INJ_UA			= 0x003,
180	CTL_LUN_INJ_CUSTOM		= 0x004,
181	CTL_LUN_INJ_TYPE		= 0x0ff,
182	CTL_LUN_INJ_CONTINUOUS		= 0x100,
183	CTL_LUN_INJ_DESCRIPTOR		= 0x200
184} ctl_lun_error;
185
186/*
187 * Flags to specify what type of command the given error pattern will
188 * execute on.  The first group of types can be ORed together.
189 *
190 * READ:	Any read command.
191 * WRITE:	Any write command.
192 * READWRITE:	Any read or write command.
193 * READCAP:	Any read capacity command.
194 * TUR:		Test Unit Ready.
195 * ANY:		Any command.
196 * MASK:	Mask for basic command patterns.
197 *
198 * Special types:
199 *
200 * CMD:		The CDB to act on is specified in struct ctl_error_desc_cmd.
201 * RANGE:	For read/write commands, act when the LBA is in the
202 *		specified range.
203 */
204typedef enum {
205	CTL_LUN_PAT_NONE	= 0x000,
206	CTL_LUN_PAT_READ	= 0x001,
207	CTL_LUN_PAT_WRITE	= 0x002,
208	CTL_LUN_PAT_READWRITE	= CTL_LUN_PAT_READ | CTL_LUN_PAT_WRITE,
209	CTL_LUN_PAT_READCAP	= 0x004,
210	CTL_LUN_PAT_TUR		= 0x008,
211	CTL_LUN_PAT_ANY		= 0x0ff,
212	CTL_LUN_PAT_MASK	= 0x0ff,
213	CTL_LUN_PAT_CMD		= 0x100,
214	CTL_LUN_PAT_RANGE	= 0x200
215} ctl_lun_error_pattern;
216
217/*
218 * This structure allows the user to specify a particular CDB pattern to
219 * look for.
220 *
221 * cdb_pattern:		Fill in the relevant bytes to look for in the CDB.
222 * cdb_valid_bytes:	Bitmask specifying valid bytes in the cdb_pattern.
223 * flags:		Specify any command flags (see ctl_io_flags) that
224 *			should be set.
225 */
226struct ctl_error_desc_cmd {
227	uint8_t		cdb_pattern[CTL_MAX_CDBLEN];
228	uint32_t	cdb_valid_bytes;
229	uint32_t	flags;
230};
231
232/*
233 * Error injection descriptor.
234 *
235 * lun_id	   LUN to act on.
236 * lun_error:	   The type of error to inject.  See above for descriptions.
237 * error_pattern:  What kind of command to act on.  See above.
238 * cmd_desc:	   For CTL_LUN_PAT_CMD only.
239 * lba_range:	   For CTL_LUN_PAT_RANGE only.
240 * custom_sense:   Specify sense.  For CTL_LUN_INJ_CUSTOM only.
241 * serial:	   Serial number returned by the kernel.  Use for deletion.
242 * links:	   Kernel use only.
243 */
244struct ctl_error_desc {
245	uint32_t			lun_id;		/* To kernel */
246	ctl_lun_error			lun_error;	/* To kernel */
247	ctl_lun_error_pattern		error_pattern;	/* To kernel */
248	struct ctl_error_desc_cmd	cmd_desc;	/* To kernel */
249	struct ctl_lba_len		lba_range;	/* To kernel */
250	struct scsi_sense_data		custom_sense;	/* To kernel */
251	uint64_t			serial;		/* From kernel */
252	STAILQ_ENTRY(ctl_error_desc)	links;		/* Kernel use only */
253};
254
255typedef enum {
256	CTL_OOA_FLAG_NONE	= 0x00,
257	CTL_OOA_FLAG_ALL_LUNS	= 0x01
258} ctl_ooa_flags;
259
260typedef enum {
261	CTL_OOA_OK,
262	CTL_OOA_NEED_MORE_SPACE,
263	CTL_OOA_ERROR
264} ctl_get_ooa_status;
265
266typedef enum {
267	CTL_OOACMD_FLAG_NONE		= 0x00,
268	CTL_OOACMD_FLAG_DMA		= 0x01,
269	CTL_OOACMD_FLAG_BLOCKED		= 0x02,
270	CTL_OOACMD_FLAG_ABORT		= 0x04,
271	CTL_OOACMD_FLAG_RTR		= 0x08,
272	CTL_OOACMD_FLAG_DMA_QUEUED	= 0x10
273} ctl_ooa_cmd_flags;
274
275struct ctl_ooa_entry {
276	ctl_ooa_cmd_flags	cmd_flags;
277	uint8_t			cdb[CTL_MAX_CDBLEN];
278	uint8_t			cdb_len;
279	uint32_t		tag_num;
280	uint32_t		lun_num;
281	struct bintime		start_bt;
282};
283
284struct ctl_ooa {
285	ctl_ooa_flags		flags;		/* passed to kernel */
286	uint64_t		lun_num;	/* passed to kernel */
287	uint32_t		alloc_len;	/* passed to kernel */
288	uint32_t		alloc_num;	/* passed to kernel */
289	struct ctl_ooa_entry	*entries;	/* filled in kernel */
290	uint32_t		fill_len;	/* passed to userland */
291	uint32_t		fill_num;	/* passed to userland */
292	uint32_t		dropped_num;	/* passed to userland */
293	struct bintime		cur_bt;		/* passed to userland */
294	ctl_get_ooa_status	status;		/* passed to userland */
295};
296
297typedef enum {
298	CTL_LUN_NOSTATUS,
299	CTL_LUN_OK,
300	CTL_LUN_ERROR,
301	CTL_LUN_WARNING
302} ctl_lun_status;
303
304#define	CTL_ERROR_STR_LEN	160
305
306#define	CTL_BEARG_RD		0x01
307#define	CTL_BEARG_WR		0x02
308#define	CTL_BEARG_RW		(CTL_BEARG_RD|CTL_BEARG_WR)
309#define	CTL_BEARG_ASCII		0x04
310
311/*
312 * Backend Argument:
313 *
314 * namelen:	Length of the name field, including the terminating NUL.
315 *
316 * name:	Name of the paramter.  This must be NUL-terminated.
317 *
318 * flags:	Flags for the parameter, see above for values.
319 *
320 * vallen:	Length of the value in bytes.
321 *
322 * value:	Value to be set/fetched.
323 *
324 * kname:	For kernel use only.
325 *
326 * kvalue:	For kernel use only.
327 */
328struct ctl_be_arg {
329	int	namelen;
330	char	*name;
331	int	flags;
332	int	vallen;
333	void	*value;
334
335	char	*kname;
336	void	*kvalue;
337};
338
339typedef enum {
340	CTL_LUNREQ_CREATE,
341	CTL_LUNREQ_RM,
342	CTL_LUNREQ_MODIFY,
343} ctl_lunreq_type;
344
345
346/*
347 * LUN creation parameters:
348 *
349 * flags:		Various LUN flags, see ctl_backend.h for a
350 *			description of the flag values and meanings.
351 *
352 * device_type:		The SCSI device type.  e.g. 0 for Direct Access,
353 *			3 for Processor, etc.  Only certain backends may
354 *			support setting this field.  The CTL_LUN_FLAG_DEV_TYPE
355 *			flag should be set in the flags field if the device
356 *			type is set.
357 *
358 * lun_size_bytes:	The size of the LUN in bytes.  For some backends
359 *			this is relevant (e.g. ramdisk), for others, it may
360 *			be ignored in favor of using the properties of the
361 *			backing store.  If specified, this should be a
362 *			multiple of the blocksize.
363 *
364 *			The actual size of the LUN is returned in this
365 *			field.
366 *
367 * blocksize_bytes:	The LUN blocksize in bytes.  For some backends this
368 *			is relevant, for others it may be ignored in
369 *			favor of using the properties of the backing store.
370 *
371 *			The actual blocksize of the LUN is returned in this
372 *			field.
373 *
374 * req_lun_id:		The requested LUN ID.  The CTL_LUN_FLAG_ID_REQ flag
375 *			should be set if this is set.  The request will be
376 *			granted if the LUN number is available, otherwise
377 * 			the LUN addition request will fail.
378 *
379 *			The allocated LUN number is returned in this field.
380 *
381 * serial_num:		This is the value returned in SCSI INQUIRY VPD page
382 *			0x80.  If it is specified, the CTL_LUN_FLAG_SERIAL_NUM
383 *			flag should be set.
384 *
385 *			The serial number value used is returned in this
386 *			field.
387 *
388 * device_id:		This is the value returned in the T10 vendor ID
389 *			based DESIGNATOR field in the SCSI INQUIRY VPD page
390 *			0x83 data.  If it is specified, the CTL_LUN_FLAG_DEVID
391 *			flag should be set.
392 *
393 *			The device id value used is returned in this field.
394 */
395struct ctl_lun_create_params {
396	ctl_backend_lun_flags	flags;
397	uint8_t			device_type;
398	uint64_t		lun_size_bytes;
399	uint32_t		blocksize_bytes;
400	uint32_t		req_lun_id;
401	uint8_t			serial_num[CTL_SN_LEN];
402	uint8_t			device_id[CTL_DEVID_LEN];
403};
404
405/*
406 * LUN removal parameters:
407 *
408 * lun_id:		The number of the LUN to delete.  This must be set.
409 *			The LUN must be backed by the given backend.
410 */
411struct ctl_lun_rm_params {
412	uint32_t		lun_id;
413};
414
415/*
416 * LUN modification parameters:
417 *
418 * lun_id:		The number of the LUN to modify.  This must be set.
419 *			The LUN must be backed by the given backend.
420 *
421 * lun_size_bytes:	The size of the LUN in bytes.  If zero, update
422 * 			the size using the backing file size, if possible.
423 */
424struct ctl_lun_modify_params {
425	uint32_t		lun_id;
426	uint64_t		lun_size_bytes;
427};
428
429/*
430 * Union of request type data.  Fill in the appropriate union member for
431 * the request type.
432 */
433union ctl_lunreq_data {
434	struct ctl_lun_create_params	create;
435	struct ctl_lun_rm_params	rm;
436	struct ctl_lun_modify_params	modify;
437};
438
439/*
440 * LUN request interface:
441 *
442 * backend:		This is required, and is NUL-terminated a string
443 *			that is the name of the backend, like "ramdisk" or
444 *			"block".
445 *
446 * reqtype:		The type of request, CTL_LUNREQ_CREATE to create a
447 *			LUN, CTL_LUNREQ_RM to delete a LUN.
448 *
449 * reqdata:		Request type-specific information.  See the
450 *			description of individual the union members above
451 *			for more information.
452 *
453 * num_be_args:		This is the number of backend-specific arguments
454 *			in the be_args array.
455 *
456 * be_args:		This is an array of backend-specific arguments.
457 *			See above for a description of the fields in this
458 *			structure.
459 *
460 * status:		Status of the LUN request.
461 *
462 * error_str:		If the status is CTL_LUN_ERROR, this will
463 *			contain a string describing the error.
464 *
465 * kern_be_args:	For kernel use only.
466 */
467struct ctl_lun_req {
468	char			backend[CTL_BE_NAME_LEN];
469	ctl_lunreq_type		reqtype;
470	union ctl_lunreq_data	reqdata;
471	int			num_be_args;
472	struct ctl_be_arg	*be_args;
473	ctl_lun_status		status;
474	char			error_str[CTL_ERROR_STR_LEN];
475	struct ctl_be_arg	*kern_be_args;
476};
477
478/*
479 * LUN list status:
480 *
481 * NONE:		No status.
482 *
483 * OK:			Request completed successfully.
484 *
485 * NEED_MORE_SPACE:	The allocated length of the entries field is too
486 * 			small for the available data.
487 *
488 * ERROR:		An error occured, look at the error string for a
489 *			description of the error.
490 */
491typedef enum {
492	CTL_LUN_LIST_NONE,
493	CTL_LUN_LIST_OK,
494	CTL_LUN_LIST_NEED_MORE_SPACE,
495	CTL_LUN_LIST_ERROR
496} ctl_lun_list_status;
497
498/*
499 * LUN list interface
500 *
501 * backend_name:	This is a NUL-terminated string.  If the string
502 *			length is 0, then all LUNs on all backends will
503 *			be enumerated.  Otherwise this is the name of the
504 *			backend to be enumerated, like "ramdisk" or "block".
505 *
506 * alloc_len:		The length of the data buffer allocated for entries.
507 *			In order to properly size the buffer, make one call
508 *			with alloc_len set to 0, and then use the returned
509 *			dropped_len as the buffer length to allocate and
510 *			pass in on a subsequent call.
511 *
512 * lun_xml:		XML-formatted information on the requested LUNs.
513 *
514 * fill_len:		The amount of data filled in the storage for entries.
515 *
516 * status:		The status of the request.  See above for the
517 *			description of the values of this field.
518 *
519 * error_str:		If the status indicates an error, this string will
520 *			be filled in to describe the error.
521 */
522struct ctl_lun_list {
523	char			backend[CTL_BE_NAME_LEN]; /* passed to kernel*/
524	uint32_t		alloc_len;	/* passed to kernel */
525	char                   *lun_xml;	/* filled in kernel */
526	uint32_t		fill_len;	/* passed to userland */
527	ctl_lun_list_status	status;		/* passed to userland */
528	char			error_str[CTL_ERROR_STR_LEN];
529						/* passed to userland */
530};
531
532/*
533 * Port request interface:
534 *
535 * driver:		This is required, and is NUL-terminated a string
536 *			that is the name of the frontend, like "iscsi" .
537 *
538 * reqtype:		The type of request, CTL_REQ_CREATE to create a
539 *			port, CTL_REQ_REMOVE to delete a port.
540 *
541 * num_be_args:		This is the number of frontend-specific arguments
542 *			in the be_args array.
543 *
544 * be_args:		This is an array of frontend-specific arguments.
545 *			See above for a description of the fields in this
546 *			structure.
547 *
548 * status:		Status of the request.
549 *
550 * error_str:		If the status is CTL_LUN_ERROR, this will
551 *			contain a string describing the error.
552 *
553 * kern_be_args:	For kernel use only.
554 */
555typedef enum {
556	CTL_REQ_CREATE,
557	CTL_REQ_REMOVE,
558	CTL_REQ_MODIFY,
559} ctl_req_type;
560
561struct ctl_req {
562	char			driver[CTL_DRIVER_NAME_LEN];
563	ctl_req_type		reqtype;
564	int			num_args;
565	struct ctl_be_arg	*args;
566	ctl_lun_status		status;
567	char			error_str[CTL_ERROR_STR_LEN];
568	struct ctl_be_arg	*kern_args;
569};
570
571/*
572 * iSCSI status
573 *
574 * OK:			Request completed successfully.
575 *
576 * ERROR:		An error occured, look at the error string for a
577 *			description of the error.
578 *
579 * CTL_ISCSI_LIST_NEED_MORE_SPACE:
580 * 			User has to pass larger buffer for CTL_ISCSI_LIST ioctl.
581 */
582typedef enum {
583	CTL_ISCSI_OK,
584	CTL_ISCSI_ERROR,
585	CTL_ISCSI_LIST_NEED_MORE_SPACE,
586	CTL_ISCSI_SESSION_NOT_FOUND
587} ctl_iscsi_status;
588
589typedef enum {
590	CTL_ISCSI_HANDOFF,
591	CTL_ISCSI_LIST,
592	CTL_ISCSI_LOGOUT,
593	CTL_ISCSI_TERMINATE,
594#if defined(ICL_KERNEL_PROXY) || 1
595	/*
596	 * We actually need those in all cases, but leave the ICL_KERNEL_PROXY,
597	 * to remember to remove them along with rest of proxy code, eventually.
598	 */
599	CTL_ISCSI_LISTEN,
600	CTL_ISCSI_ACCEPT,
601	CTL_ISCSI_SEND,
602	CTL_ISCSI_RECEIVE,
603#endif
604} ctl_iscsi_type;
605
606typedef enum {
607	CTL_ISCSI_DIGEST_NONE,
608	CTL_ISCSI_DIGEST_CRC32C
609} ctl_iscsi_digest;
610
611#define	CTL_ISCSI_NAME_LEN	224	/* 223 bytes, by RFC 3720, + '\0' */
612#define	CTL_ISCSI_ADDR_LEN	47	/* INET6_ADDRSTRLEN + '\0' */
613#define	CTL_ISCSI_ALIAS_LEN	128	/* Arbitrary. */
614
615struct ctl_iscsi_handoff_params {
616	char			initiator_name[CTL_ISCSI_NAME_LEN];
617	char			initiator_addr[CTL_ISCSI_ADDR_LEN];
618	char			initiator_alias[CTL_ISCSI_ALIAS_LEN];
619	uint8_t			initiator_isid[6];
620	char			target_name[CTL_ISCSI_NAME_LEN];
621	int			socket;
622	int			portal_group_tag;
623
624	/*
625	 * Connection parameters negotiated by ctld(8).
626	 */
627	ctl_iscsi_digest	header_digest;
628	ctl_iscsi_digest	data_digest;
629	uint32_t		cmdsn;
630	uint32_t		statsn;
631	uint32_t		max_recv_data_segment_length;
632	uint32_t		max_burst_length;
633	uint32_t		first_burst_length;
634	uint32_t		immediate_data;
635#ifdef ICL_KERNEL_PROXY
636	int			connection_id;
637	int			spare[3];
638#else
639	int			spare[4];
640#endif
641};
642
643struct ctl_iscsi_list_params {
644	uint32_t		alloc_len;	/* passed to kernel */
645	char                   *conn_xml;	/* filled in kernel */
646	uint32_t		fill_len;	/* passed to userland */
647	int			spare[4];
648};
649
650struct ctl_iscsi_logout_params {
651	int			connection_id;	/* passed to kernel */
652	char			initiator_name[CTL_ISCSI_NAME_LEN];
653						/* passed to kernel */
654	char			initiator_addr[CTL_ISCSI_ADDR_LEN];
655						/* passed to kernel */
656	int			all;		/* passed to kernel */
657	int			spare[4];
658};
659
660struct ctl_iscsi_terminate_params {
661	int			connection_id;	/* passed to kernel */
662	char			initiator_name[CTL_ISCSI_NAME_LEN];
663						/* passed to kernel */
664	char			initiator_addr[CTL_ISCSI_NAME_LEN];
665						/* passed to kernel */
666	int			all;		/* passed to kernel */
667	int			spare[4];
668};
669
670#ifdef ICL_KERNEL_PROXY
671struct ctl_iscsi_listen_params {
672	int				iser;
673	int				domain;
674	int				socktype;
675	int				protocol;
676	struct sockaddr			*addr;
677	socklen_t			addrlen;
678	int				portal_id;
679	int				spare[4];
680};
681
682struct ctl_iscsi_accept_params {
683	int				connection_id;
684	int				portal_id;
685	struct sockaddr			*initiator_addr;
686	socklen_t			initiator_addrlen;
687	int				spare[4];
688};
689
690struct ctl_iscsi_send_params {
691	int				connection_id;
692	void				*bhs;
693	size_t				spare;
694	void				*spare2;
695	size_t				data_segment_len;
696	void				*data_segment;
697	int				spare3[4];
698};
699
700struct ctl_iscsi_receive_params {
701	int				connection_id;
702	void				*bhs;
703	size_t				spare;
704	void				*spare2;
705	size_t				data_segment_len;
706	void				*data_segment;
707	int				spare3[4];
708};
709
710#endif /* ICL_KERNEL_PROXY */
711
712union ctl_iscsi_data {
713	struct ctl_iscsi_handoff_params		handoff;
714	struct ctl_iscsi_list_params		list;
715	struct ctl_iscsi_logout_params		logout;
716	struct ctl_iscsi_terminate_params	terminate;
717#ifdef ICL_KERNEL_PROXY
718	struct ctl_iscsi_listen_params		listen;
719	struct ctl_iscsi_accept_params		accept;
720	struct ctl_iscsi_send_params		send;
721	struct ctl_iscsi_receive_params		receive;
722#endif
723};
724
725/*
726 * iSCSI interface
727 *
728 * status:		The status of the request.  See above for the
729 *			description of the values of this field.
730 *
731 * error_str:		If the status indicates an error, this string will
732 *			be filled in to describe the error.
733 */
734struct ctl_iscsi {
735	ctl_iscsi_type		type;		/* passed to kernel */
736	union ctl_iscsi_data	data;		/* passed to kernel */
737	ctl_iscsi_status	status;		/* passed to userland */
738	char			error_str[CTL_ERROR_STR_LEN];
739						/* passed to userland */
740};
741
742struct ctl_lun_map {
743	uint32_t		port;
744	uint32_t		plun;
745	uint32_t		lun;
746};
747
748#define	CTL_IO			_IOWR(CTL_MINOR, 0x00, union ctl_io)
749#define	CTL_ENABLE_PORT		_IOW(CTL_MINOR, 0x04, struct ctl_port_entry)
750#define	CTL_DISABLE_PORT	_IOW(CTL_MINOR, 0x05, struct ctl_port_entry)
751#define	CTL_DELAY_IO		_IOWR(CTL_MINOR, 0x10, struct ctl_io_delay_info)
752#define	CTL_GETSTATS		_IOWR(CTL_MINOR, 0x15, struct ctl_stats)
753#define	CTL_ERROR_INJECT	_IOWR(CTL_MINOR, 0x16, struct ctl_error_desc)
754#define	CTL_GET_OOA		_IOWR(CTL_MINOR, 0x18, struct ctl_ooa)
755#define	CTL_DUMP_STRUCTS	_IO(CTL_MINOR, 0x19)
756#define	CTL_LUN_REQ		_IOWR(CTL_MINOR, 0x21, struct ctl_lun_req)
757#define	CTL_LUN_LIST		_IOWR(CTL_MINOR, 0x22, struct ctl_lun_list)
758#define	CTL_ERROR_INJECT_DELETE	_IOW(CTL_MINOR, 0x23, struct ctl_error_desc)
759#define	CTL_SET_PORT_WWNS	_IOW(CTL_MINOR, 0x24, struct ctl_port_entry)
760#define	CTL_ISCSI		_IOWR(CTL_MINOR, 0x25, struct ctl_iscsi)
761#define	CTL_PORT_REQ		_IOWR(CTL_MINOR, 0x26, struct ctl_req)
762#define	CTL_PORT_LIST		_IOWR(CTL_MINOR, 0x27, struct ctl_lun_list)
763#define	CTL_LUN_MAP		_IOW(CTL_MINOR, 0x28, struct ctl_lun_map)
764
765#endif /* _CTL_IOCTL_H_ */
766
767/*
768 * vim: ts=8
769 */
770