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