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