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