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