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