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