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_DELAY_TYPE_NONE, 85 CTL_DELAY_TYPE_CONT, 86 CTL_DELAY_TYPE_ONESHOT 87 } ctl_delay_type; 88 89 typedef enum { 90 CTL_DELAY_LOC_NONE, 91 CTL_DELAY_LOC_DATAMOVE, 92 CTL_DELAY_LOC_DONE, 93 } ctl_delay_location; 94 95 typedef 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 104 struct 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 112 typedef 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 119 typedef enum { 120 CTL_LUN_STATS_NO_BLOCKSIZE = 0x01 121 } ctl_lun_stats_flags; 122 123 struct 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 132 struct 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 140 typedef enum { 141 CTL_SS_OK, 142 CTL_SS_NEED_MORE_SPACE, 143 CTL_SS_ERROR 144 } ctl_stats_status; 145 146 typedef enum { 147 CTL_STATS_FLAG_NONE = 0x00, 148 CTL_STATS_FLAG_TIME_VALID = 0x01 149 } ctl_stats_flags; 150 151 struct 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 */ 175 typedef 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 */ 204 typedef 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 */ 226 struct 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 */ 244 struct 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 255 typedef enum { 256 CTL_OOA_FLAG_NONE = 0x00, 257 CTL_OOA_FLAG_ALL_LUNS = 0x01 258 } ctl_ooa_flags; 259 260 typedef enum { 261 CTL_OOA_OK, 262 CTL_OOA_NEED_MORE_SPACE, 263 CTL_OOA_ERROR 264 } ctl_get_ooa_status; 265 266 typedef 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 275 struct 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 284 struct 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 297 typedef 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 parameter. 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 */ 328 struct 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 339 typedef 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 */ 395 struct 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 */ 411 struct 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 */ 424 struct 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 */ 433 union 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 */ 467 struct 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 occurred, look at the error string for a 489 * description of the error. 490 */ 491 typedef 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 */ 522 struct 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 */ 555 typedef enum { 556 CTL_REQ_CREATE, 557 CTL_REQ_REMOVE, 558 CTL_REQ_MODIFY, 559 } ctl_req_type; 560 561 struct 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 occurred, 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 */ 582 typedef 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 589 typedef enum { 590 CTL_ISCSI_HANDOFF, 591 CTL_ISCSI_LIST, 592 CTL_ISCSI_LOGOUT, 593 CTL_ISCSI_TERMINATE, 594 CTL_ISCSI_LIMITS, 595 #if defined(ICL_KERNEL_PROXY) || 1 596 /* 597 * We actually need those in all cases, but leave the ICL_KERNEL_PROXY, 598 * to remember to remove them along with rest of proxy code, eventually. 599 */ 600 CTL_ISCSI_LISTEN, 601 CTL_ISCSI_ACCEPT, 602 CTL_ISCSI_SEND, 603 CTL_ISCSI_RECEIVE, 604 #endif 605 } ctl_iscsi_type; 606 607 typedef enum { 608 CTL_ISCSI_DIGEST_NONE, 609 CTL_ISCSI_DIGEST_CRC32C 610 } ctl_iscsi_digest; 611 612 #define CTL_ISCSI_NAME_LEN 224 /* 223 bytes, by RFC 3720, + '\0' */ 613 #define CTL_ISCSI_ADDR_LEN 47 /* INET6_ADDRSTRLEN + '\0' */ 614 #define CTL_ISCSI_ALIAS_LEN 128 /* Arbitrary. */ 615 #define CTL_ISCSI_OFFLOAD_LEN 8 /* Arbitrary. */ 616 617 struct ctl_iscsi_handoff_params { 618 char initiator_name[CTL_ISCSI_NAME_LEN]; 619 char initiator_addr[CTL_ISCSI_ADDR_LEN]; 620 char initiator_alias[CTL_ISCSI_ALIAS_LEN]; 621 uint8_t initiator_isid[6]; 622 char target_name[CTL_ISCSI_NAME_LEN]; 623 int socket; 624 int portal_group_tag; 625 626 /* 627 * Connection parameters negotiated by ctld(8). 628 */ 629 ctl_iscsi_digest header_digest; 630 ctl_iscsi_digest data_digest; 631 uint32_t cmdsn; 632 uint32_t statsn; 633 uint32_t max_recv_data_segment_length; 634 uint32_t max_burst_length; 635 uint32_t first_burst_length; 636 uint32_t immediate_data; 637 char offload[CTL_ISCSI_OFFLOAD_LEN]; 638 #ifdef ICL_KERNEL_PROXY 639 int connection_id; 640 int spare[1]; 641 #else 642 int spare[2]; 643 #endif 644 }; 645 646 struct ctl_iscsi_list_params { 647 uint32_t alloc_len; /* passed to kernel */ 648 char *conn_xml; /* filled in kernel */ 649 uint32_t fill_len; /* passed to userland */ 650 int spare[4]; 651 }; 652 653 struct ctl_iscsi_logout_params { 654 int connection_id; /* passed to kernel */ 655 char initiator_name[CTL_ISCSI_NAME_LEN]; 656 /* passed to kernel */ 657 char initiator_addr[CTL_ISCSI_ADDR_LEN]; 658 /* passed to kernel */ 659 int all; /* passed to kernel */ 660 int spare[4]; 661 }; 662 663 struct ctl_iscsi_terminate_params { 664 int connection_id; /* passed to kernel */ 665 char initiator_name[CTL_ISCSI_NAME_LEN]; 666 /* passed to kernel */ 667 char initiator_addr[CTL_ISCSI_NAME_LEN]; 668 /* passed to kernel */ 669 int all; /* passed to kernel */ 670 int spare[4]; 671 }; 672 673 struct ctl_iscsi_limits_params { 674 char offload[CTL_ISCSI_OFFLOAD_LEN]; 675 /* passed to kernel */ 676 size_t data_segment_limit; 677 /* passed to userland */ 678 int spare[4]; 679 }; 680 681 #ifdef ICL_KERNEL_PROXY 682 struct ctl_iscsi_listen_params { 683 int iser; 684 int domain; 685 int socktype; 686 int protocol; 687 struct sockaddr *addr; 688 socklen_t addrlen; 689 int portal_id; 690 int spare[4]; 691 }; 692 693 struct ctl_iscsi_accept_params { 694 int connection_id; 695 int portal_id; 696 struct sockaddr *initiator_addr; 697 socklen_t initiator_addrlen; 698 int spare[4]; 699 }; 700 701 struct ctl_iscsi_send_params { 702 int connection_id; 703 void *bhs; 704 size_t spare; 705 void *spare2; 706 size_t data_segment_len; 707 void *data_segment; 708 int spare3[4]; 709 }; 710 711 struct ctl_iscsi_receive_params { 712 int connection_id; 713 void *bhs; 714 size_t spare; 715 void *spare2; 716 size_t data_segment_len; 717 void *data_segment; 718 int spare3[4]; 719 }; 720 721 #endif /* ICL_KERNEL_PROXY */ 722 723 union ctl_iscsi_data { 724 struct ctl_iscsi_handoff_params handoff; 725 struct ctl_iscsi_list_params list; 726 struct ctl_iscsi_logout_params logout; 727 struct ctl_iscsi_terminate_params terminate; 728 struct ctl_iscsi_limits_params limits; 729 #ifdef ICL_KERNEL_PROXY 730 struct ctl_iscsi_listen_params listen; 731 struct ctl_iscsi_accept_params accept; 732 struct ctl_iscsi_send_params send; 733 struct ctl_iscsi_receive_params receive; 734 #endif 735 }; 736 737 /* 738 * iSCSI interface 739 * 740 * status: The status of the request. See above for the 741 * description of the values of this field. 742 * 743 * error_str: If the status indicates an error, this string will 744 * be filled in to describe the error. 745 */ 746 struct ctl_iscsi { 747 ctl_iscsi_type type; /* passed to kernel */ 748 union ctl_iscsi_data data; /* passed to kernel */ 749 ctl_iscsi_status status; /* passed to userland */ 750 char error_str[CTL_ERROR_STR_LEN]; 751 /* passed to userland */ 752 }; 753 754 struct ctl_lun_map { 755 uint32_t port; 756 uint32_t plun; 757 uint32_t lun; 758 }; 759 760 #define CTL_IO _IOWR(CTL_MINOR, 0x00, union ctl_io) 761 #define CTL_ENABLE_PORT _IOW(CTL_MINOR, 0x04, struct ctl_port_entry) 762 #define CTL_DISABLE_PORT _IOW(CTL_MINOR, 0x05, struct ctl_port_entry) 763 #define CTL_DELAY_IO _IOWR(CTL_MINOR, 0x10, struct ctl_io_delay_info) 764 #define CTL_GETSTATS _IOWR(CTL_MINOR, 0x15, struct ctl_stats) 765 #define CTL_ERROR_INJECT _IOWR(CTL_MINOR, 0x16, struct ctl_error_desc) 766 #define CTL_GET_OOA _IOWR(CTL_MINOR, 0x18, struct ctl_ooa) 767 #define CTL_DUMP_STRUCTS _IO(CTL_MINOR, 0x19) 768 #define CTL_LUN_REQ _IOWR(CTL_MINOR, 0x21, struct ctl_lun_req) 769 #define CTL_LUN_LIST _IOWR(CTL_MINOR, 0x22, struct ctl_lun_list) 770 #define CTL_ERROR_INJECT_DELETE _IOW(CTL_MINOR, 0x23, struct ctl_error_desc) 771 #define CTL_SET_PORT_WWNS _IOW(CTL_MINOR, 0x24, struct ctl_port_entry) 772 #define CTL_ISCSI _IOWR(CTL_MINOR, 0x25, struct ctl_iscsi) 773 #define CTL_PORT_REQ _IOWR(CTL_MINOR, 0x26, struct ctl_req) 774 #define CTL_PORT_LIST _IOWR(CTL_MINOR, 0x27, struct ctl_lun_list) 775 #define CTL_LUN_MAP _IOW(CTL_MINOR, 0x28, struct ctl_lun_map) 776 777 #endif /* _CTL_IOCTL_H_ */ 778 779 /* 780 * vim: ts=8 781 */ 782