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