ctl_ioctl.h revision 265509
1254721Semaste/*- 2254721Semaste * Copyright (c) 2003 Silicon Graphics International Corp. 3254721Semaste * Copyright (c) 2011 Spectra Logic Corporation 4254721Semaste * All rights reserved. 5254721Semaste * 6254721Semaste * Redistribution and use in source and binary forms, with or without 7254721Semaste * modification, are permitted provided that the following conditions 8254721Semaste * are met: 9254721Semaste * 1. Redistributions of source code must retain the above copyright 10254721Semaste * notice, this list of conditions, and the following disclaimer, 11254721Semaste * without modification. 12254721Semaste * 2. Redistributions in binary form must reproduce at minimum a disclaimer 13254721Semaste * substantially similar to the "NO WARRANTY" disclaimer below 14254721Semaste * ("Disclaimer") and any redistribution must be conditioned upon 15254721Semaste * including a substantially similar Disclaimer requirement for further 16254721Semaste * binary redistribution. 17254721Semaste * 18254721Semaste * NO WARRANTY 19254721Semaste * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20254721Semaste * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21254721Semaste * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 22254721Semaste * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23254721Semaste * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24254721Semaste * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25254721Semaste * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26254721Semaste * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27254721Semaste * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 28254721Semaste * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29254721Semaste * POSSIBILITY OF SUCH DAMAGES. 30254721Semaste * 31254721Semaste * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_ioctl.h#4 $ 32254721Semaste * $FreeBSD: stable/10/sys/cam/ctl/ctl_ioctl.h 265509 2014-05-07 07:32:45Z trasz $ 33254721Semaste */ 34254721Semaste/* 35254721Semaste * CAM Target Layer ioctl interface. 36254721Semaste * 37254721Semaste * Author: Ken Merry <ken@FreeBSD.org> 38254721Semaste */ 39254721Semaste 40254721Semaste#ifndef _CTL_IOCTL_H_ 41254721Semaste#define _CTL_IOCTL_H_ 42254721Semaste 43254721Semaste#ifdef ICL_KERNEL_PROXY 44254721Semaste#include <sys/socket.h> 45254721Semaste#endif 46254721Semaste 47254721Semaste#include <sys/ioccom.h> 48254721Semaste 49254721Semaste#define CTL_DEFAULT_DEV "/dev/cam/ctl" 50254721Semaste/* 51254721Semaste * Maximum number of targets we support. 52254721Semaste */ 53254721Semaste#define CTL_MAX_TARGETS 1 54254721Semaste 55254721Semaste/* 56254721Semaste * Maximum target ID we support. 57254721Semaste */ 58254721Semaste#define CTL_MAX_TARGID 15 59254721Semaste 60254721Semaste/* 61254721Semaste * Maximum number of LUNs we support at the moment. MUST be a power of 2. 62254721Semaste */ 63254721Semaste#define CTL_MAX_LUNS 256 64254721Semaste 65254721Semaste/* 66254721Semaste * Maximum number of initiators per port. 67254721Semaste */ 68254721Semaste#define CTL_MAX_INIT_PER_PORT 2048 // Was 16 69254721Semaste 70254721Semaste/* 71254721Semaste * Maximum number of ports registered at one time. 72254721Semaste */ 73254721Semaste#define CTL_MAX_PORTS 32 74254721Semaste 75254721Semaste/* 76254721Semaste * Maximum number of initiators we support. 77254721Semaste */ 78254721Semaste#define CTL_MAX_INITIATORS (CTL_MAX_INIT_PER_PORT * CTL_MAX_PORTS) 79254721Semaste 80254721Semaste/* Hopefully this won't conflict with new misc devices that pop up */ 81254721Semaste#define CTL_MINOR 225 82254721Semaste 83254721Semastetypedef enum { 84254721Semaste CTL_OOA_INVALID_LUN, 85254721Semaste CTL_OOA_SUCCESS 86254721Semaste} ctl_ooa_status; 87254721Semaste 88254721Semastestruct ctl_ooa_info { 89254721Semaste uint32_t target_id; /* Passed in to CTL */ 90254721Semaste uint32_t lun_id; /* Passed in to CTL */ 91254721Semaste uint32_t num_entries; /* Returned from CTL */ 92254721Semaste ctl_ooa_status status; /* Returned from CTL */ 93254721Semaste}; 94254721Semaste 95254721Semastestruct ctl_hard_startstop_info { 96254721Semaste cfi_mt_status status; 97254721Semaste int total_luns; 98254721Semaste int luns_complete; 99254721Semaste int luns_failed; 100254721Semaste}; 101254721Semaste 102254721Semastestruct ctl_bbrread_info { 103254721Semaste int lun_num; /* Passed in to CTL */ 104254721Semaste uint64_t lba; /* Passed in to CTL */ 105254721Semaste int len; /* Passed in to CTL */ 106254721Semaste cfi_mt_status status; /* Returned from CTL */ 107254721Semaste cfi_bbrread_status bbr_status; /* Returned from CTL */ 108254721Semaste uint8_t scsi_status; /* Returned from CTL */ 109254721Semaste struct scsi_sense_data sense_data; /* Returned from CTL */ 110254721Semaste}; 111254721Semaste 112254721Semastetypedef enum { 113254721Semaste CTL_DELAY_TYPE_NONE, 114254721Semaste CTL_DELAY_TYPE_CONT, 115254721Semaste CTL_DELAY_TYPE_ONESHOT 116254721Semaste} ctl_delay_type; 117254721Semaste 118254721Semastetypedef enum { 119254721Semaste CTL_DELAY_LOC_NONE, 120254721Semaste CTL_DELAY_LOC_DATAMOVE, 121254721Semaste CTL_DELAY_LOC_DONE, 122254721Semaste} ctl_delay_location; 123254721Semaste 124254721Semastetypedef enum { 125254721Semaste CTL_DELAY_STATUS_NONE, 126254721Semaste CTL_DELAY_STATUS_OK, 127254721Semaste CTL_DELAY_STATUS_INVALID_LUN, 128254721Semaste CTL_DELAY_STATUS_INVALID_TYPE, 129254721Semaste CTL_DELAY_STATUS_INVALID_LOC, 130254721Semaste CTL_DELAY_STATUS_NOT_IMPLEMENTED 131254721Semaste} ctl_delay_status; 132254721Semaste 133254721Semastestruct ctl_io_delay_info { 134254721Semaste uint32_t target_id; 135254721Semaste uint32_t lun_id; 136254721Semaste ctl_delay_type delay_type; 137254721Semaste ctl_delay_location delay_loc; 138254721Semaste uint32_t delay_secs; 139254721Semaste ctl_delay_status status; 140254721Semaste}; 141254721Semaste 142254721Semastetypedef enum { 143254721Semaste CTL_GS_SYNC_NONE, 144254721Semaste CTL_GS_SYNC_OK, 145254721Semaste CTL_GS_SYNC_NO_LUN 146254721Semaste} ctl_gs_sync_status; 147254721Semaste 148254721Semaste/* 149254721Semaste * The target and LUN id specify which device to modify. The sync interval 150254721Semaste * means that we will let through every N SYNCHRONIZE CACHE commands. 151254721Semaste */ 152254721Semastestruct ctl_sync_info { 153254721Semaste uint32_t target_id; /* passed to kernel */ 154254721Semaste uint32_t lun_id; /* passed to kernel */ 155254721Semaste int sync_interval; /* depends on whether get/set */ 156254721Semaste ctl_gs_sync_status status; /* passed from kernel */ 157254721Semaste}; 158254721Semaste 159254721Semastetypedef enum { 160254721Semaste CTL_STATS_NO_IO, 161254721Semaste CTL_STATS_READ, 162254721Semaste CTL_STATS_WRITE 163254721Semaste} ctl_stat_types; 164254721Semaste#define CTL_STATS_NUM_TYPES 3 165254721Semaste 166254721Semastetypedef enum { 167254721Semaste CTL_LUN_STATS_NO_BLOCKSIZE = 0x01 168254721Semaste} ctl_lun_stats_flags; 169254721Semaste 170254721Semastestruct ctl_lun_io_port_stats { 171254721Semaste uint32_t targ_port; 172254721Semaste uint64_t bytes[CTL_STATS_NUM_TYPES]; 173254721Semaste uint64_t operations[CTL_STATS_NUM_TYPES]; 174254721Semaste struct bintime time[CTL_STATS_NUM_TYPES]; 175254721Semaste uint64_t num_dmas[CTL_STATS_NUM_TYPES]; 176254721Semaste struct bintime dma_time[CTL_STATS_NUM_TYPES]; 177254721Semaste}; 178254721Semaste 179254721Semastestruct ctl_lun_io_stats { 180254721Semaste uint8_t device_type; 181254721Semaste uint64_t lun_number; 182254721Semaste uint32_t blocksize; 183254721Semaste ctl_lun_stats_flags flags; 184254721Semaste struct ctl_lun_io_port_stats ports[CTL_MAX_PORTS]; 185254721Semaste}; 186254721Semaste 187254721Semastetypedef enum { 188254721Semaste CTL_SS_OK, 189254721Semaste CTL_SS_NEED_MORE_SPACE, 190254721Semaste CTL_SS_ERROR 191254721Semaste} ctl_stats_status; 192254721Semaste 193254721Semastetypedef enum { 194254721Semaste CTL_STATS_FLAG_NONE = 0x00, 195 CTL_STATS_FLAG_TIME_VALID = 0x01 196} ctl_stats_flags; 197 198struct ctl_stats { 199 int alloc_len; /* passed to kernel */ 200 struct ctl_lun_io_stats *lun_stats; /* passed to/from kernel */ 201 int fill_len; /* passed to userland */ 202 int num_luns; /* passed to userland */ 203 ctl_stats_status status; /* passed to userland */ 204 ctl_stats_flags flags; /* passed to userland */ 205 struct timespec timestamp; /* passed to userland */ 206}; 207 208/* 209 * The types of errors that can be injected: 210 * 211 * NONE: No error specified. 212 * ABORTED: SSD_KEY_ABORTED_COMMAND, 0x45, 0x00 213 * MEDIUM_ERR: Medium error, different asc/ascq depending on read/write. 214 * UA: Unit attention. 215 * CUSTOM: User specifies the sense data. 216 * TYPE: Mask to use with error types. 217 * 218 * Flags that affect injection behavior: 219 * CONTINUOUS: This error will stay around until explicitly cleared. 220 * DESCRIPTOR: Use descriptor sense instead of fixed sense. 221 */ 222typedef enum { 223 CTL_LUN_INJ_NONE = 0x000, 224 CTL_LUN_INJ_ABORTED = 0x001, 225 CTL_LUN_INJ_MEDIUM_ERR = 0x002, 226 CTL_LUN_INJ_UA = 0x003, 227 CTL_LUN_INJ_CUSTOM = 0x004, 228 CTL_LUN_INJ_TYPE = 0x0ff, 229 CTL_LUN_INJ_CONTINUOUS = 0x100, 230 CTL_LUN_INJ_DESCRIPTOR = 0x200 231} ctl_lun_error; 232 233/* 234 * Flags to specify what type of command the given error pattern will 235 * execute on. The first group of types can be ORed together. 236 * 237 * READ: Any read command. 238 * WRITE: Any write command. 239 * READWRITE: Any read or write command. 240 * READCAP: Any read capacity command. 241 * TUR: Test Unit Ready. 242 * ANY: Any command. 243 * MASK: Mask for basic command patterns. 244 * 245 * Special types: 246 * 247 * CMD: The CDB to act on is specified in struct ctl_error_desc_cmd. 248 * RANGE: For read/write commands, act when the LBA is in the 249 * specified range. 250 */ 251typedef enum { 252 CTL_LUN_PAT_NONE = 0x000, 253 CTL_LUN_PAT_READ = 0x001, 254 CTL_LUN_PAT_WRITE = 0x002, 255 CTL_LUN_PAT_READWRITE = CTL_LUN_PAT_READ | CTL_LUN_PAT_WRITE, 256 CTL_LUN_PAT_READCAP = 0x004, 257 CTL_LUN_PAT_TUR = 0x008, 258 CTL_LUN_PAT_ANY = 0x0ff, 259 CTL_LUN_PAT_MASK = 0x0ff, 260 CTL_LUN_PAT_CMD = 0x100, 261 CTL_LUN_PAT_RANGE = 0x200 262} ctl_lun_error_pattern; 263 264/* 265 * This structure allows the user to specify a particular CDB pattern to 266 * look for. 267 * 268 * cdb_pattern: Fill in the relevant bytes to look for in the CDB. 269 * cdb_valid_bytes: Bitmask specifying valid bytes in the cdb_pattern. 270 * flags: Specify any command flags (see ctl_io_flags) that 271 * should be set. 272 */ 273struct ctl_error_desc_cmd { 274 uint8_t cdb_pattern[CTL_MAX_CDBLEN]; 275 uint32_t cdb_valid_bytes; 276 uint32_t flags; 277}; 278 279/* 280 * Error injection descriptor. 281 * 282 * target_id: Target ID to act on. 283 * lun_id LUN to act on. 284 * lun_error: The type of error to inject. See above for descriptions. 285 * error_pattern: What kind of command to act on. See above. 286 * cmd_desc: For CTL_LUN_PAT_CMD only. 287 * lba_range: For CTL_LUN_PAT_RANGE only. 288 * custom_sense: Specify sense. For CTL_LUN_INJ_CUSTOM only. 289 * serial: Serial number returned by the kernel. Use for deletion. 290 * links: Kernel use only. 291 */ 292struct ctl_error_desc { 293 uint32_t target_id; /* To kernel */ 294 uint32_t lun_id; /* To kernel */ 295 ctl_lun_error lun_error; /* To kernel */ 296 ctl_lun_error_pattern error_pattern; /* To kernel */ 297 struct ctl_error_desc_cmd cmd_desc; /* To kernel */ 298 struct ctl_lba_len lba_range; /* To kernel */ 299 struct scsi_sense_data custom_sense; /* To kernel */ 300 uint64_t serial; /* From kernel */ 301 STAILQ_ENTRY(ctl_error_desc) links; /* Kernel use only */ 302}; 303 304typedef enum { 305 CTL_OOA_FLAG_NONE = 0x00, 306 CTL_OOA_FLAG_ALL_LUNS = 0x01 307} ctl_ooa_flags; 308 309typedef enum { 310 CTL_OOA_OK, 311 CTL_OOA_NEED_MORE_SPACE, 312 CTL_OOA_ERROR 313} ctl_get_ooa_status; 314 315typedef enum { 316 CTL_OOACMD_FLAG_NONE = 0x00, 317 CTL_OOACMD_FLAG_DMA = 0x01, 318 CTL_OOACMD_FLAG_BLOCKED = 0x02, 319 CTL_OOACMD_FLAG_ABORT = 0x04, 320 CTL_OOACMD_FLAG_RTR = 0x08, 321 CTL_OOACMD_FLAG_DMA_QUEUED = 0x10 322} ctl_ooa_cmd_flags; 323 324struct ctl_ooa_entry { 325 ctl_ooa_cmd_flags cmd_flags; 326 uint8_t cdb[CTL_MAX_CDBLEN]; 327 uint8_t cdb_len; 328 uint32_t tag_num; 329 uint32_t lun_num; 330 struct bintime start_bt; 331}; 332 333struct ctl_ooa { 334 ctl_ooa_flags flags; /* passed to kernel */ 335 uint64_t lun_num; /* passed to kernel */ 336 uint32_t alloc_len; /* passed to kernel */ 337 uint32_t alloc_num; /* passed to kernel */ 338 struct ctl_ooa_entry *entries; /* filled in kernel */ 339 uint32_t fill_len; /* passed to userland */ 340 uint32_t fill_num; /* passed to userland */ 341 uint32_t dropped_num; /* passed to userland */ 342 struct bintime cur_bt; /* passed to userland */ 343 ctl_get_ooa_status status; /* passed to userland */ 344}; 345 346typedef enum { 347 CTL_PORT_LIST_NONE, 348 CTL_PORT_LIST_OK, 349 CTL_PORT_LIST_NEED_MORE_SPACE, 350 CTL_PORT_LIST_ERROR 351} ctl_port_list_status; 352 353struct ctl_port_list { 354 uint32_t alloc_len; /* passed to kernel */ 355 uint32_t alloc_num; /* passed to kernel */ 356 struct ctl_port_entry *entries; /* filled in kernel */ 357 uint32_t fill_len; /* passed to userland */ 358 uint32_t fill_num; /* passed to userland */ 359 uint32_t dropped_num; /* passed to userland */ 360 ctl_port_list_status status; /* passed to userland */ 361}; 362 363typedef enum { 364 CTL_LUN_NOSTATUS, 365 CTL_LUN_OK, 366 CTL_LUN_ERROR 367} ctl_lun_status; 368 369#define CTL_ERROR_STR_LEN 160 370 371#define CTL_BEARG_RD 0x01 372#define CTL_BEARG_WR 0x02 373#define CTL_BEARG_RW (CTL_BEARG_RD|CTL_BEARG_WR) 374#define CTL_BEARG_ASCII 0x04 375 376/* 377 * Backend Argument: 378 * 379 * namelen: Length of the name field, including the terminating NUL. 380 * 381 * name: Name of the paramter. This must be NUL-terminated. 382 * 383 * flags: Flags for the parameter, see above for values. 384 * 385 * vallen: Length of the value in bytes. 386 * 387 * value: Value to be set/fetched. 388 * 389 * kname: For kernel use only. 390 * 391 * kvalue: For kernel use only. 392 */ 393struct ctl_be_arg { 394 int namelen; 395 char *name; 396 int flags; 397 int vallen; 398 void *value; 399 400 char *kname; 401 void *kvalue; 402}; 403 404typedef enum { 405 CTL_LUNREQ_CREATE, 406 CTL_LUNREQ_RM, 407 CTL_LUNREQ_MODIFY, 408} ctl_lunreq_type; 409 410 411/* 412 * LUN creation parameters: 413 * 414 * flags: Various LUN flags, see ctl_backend.h for a 415 * description of the flag values and meanings. 416 * 417 * device_type: The SCSI device type. e.g. 0 for Direct Access, 418 * 3 for Processor, etc. Only certain backends may 419 * support setting this field. The CTL_LUN_FLAG_DEV_TYPE 420 * flag should be set in the flags field if the device 421 * type is set. 422 * 423 * lun_size_bytes: The size of the LUN in bytes. For some backends 424 * this is relevant (e.g. ramdisk), for others, it may 425 * be ignored in favor of using the properties of the 426 * backing store. If specified, this should be a 427 * multiple of the blocksize. 428 * 429 * The actual size of the LUN is returned in this 430 * field. 431 * 432 * blocksize_bytes: The LUN blocksize in bytes. For some backends this 433 * is relevant, for others it may be ignored in 434 * favor of using the properties of the backing store. 435 * 436 * The actual blocksize of the LUN is returned in this 437 * field. 438 * 439 * req_lun_id: The requested LUN ID. The CTL_LUN_FLAG_ID_REQ flag 440 * should be set if this is set. The request will be 441 * granted if the LUN number is available, otherwise 442 * the LUN addition request will fail. 443 * 444 * The allocated LUN number is returned in this field. 445 * 446 * serial_num: This is the value returned in SCSI INQUIRY VPD page 447 * 0x80. If it is specified, the CTL_LUN_FLAG_SERIAL_NUM 448 * flag should be set. 449 * 450 * The serial number value used is returned in this 451 * field. 452 * 453 * device_id: This is the value returned in the T10 vendor ID 454 * based DESIGNATOR field in the SCSI INQUIRY VPD page 455 * 0x83 data. If it is specified, the CTL_LUN_FLAG_DEVID 456 * flag should be set. 457 * 458 * The device id value used is returned in this field. 459 */ 460struct ctl_lun_create_params { 461 ctl_backend_lun_flags flags; 462 uint8_t device_type; 463 uint64_t lun_size_bytes; 464 uint32_t blocksize_bytes; 465 uint32_t req_lun_id; 466 uint8_t serial_num[CTL_SN_LEN]; 467 uint8_t device_id[CTL_DEVID_LEN]; 468}; 469 470/* 471 * LUN removal parameters: 472 * 473 * lun_id: The number of the LUN to delete. This must be set. 474 * The LUN must be backed by the given backend. 475 */ 476struct ctl_lun_rm_params { 477 uint32_t lun_id; 478}; 479 480/* 481 * LUN modification parameters: 482 * 483 * lun_id: The number of the LUN to modify. This must be set. 484 * The LUN must be backed by the given backend. 485 * 486 * lun_size_bytes: The size of the LUN in bytes. If zero, update 487 * the size using the backing file size, if possible. 488 */ 489struct ctl_lun_modify_params { 490 uint32_t lun_id; 491 uint64_t lun_size_bytes; 492}; 493 494/* 495 * Union of request type data. Fill in the appropriate union member for 496 * the request type. 497 */ 498union ctl_lunreq_data { 499 struct ctl_lun_create_params create; 500 struct ctl_lun_rm_params rm; 501 struct ctl_lun_modify_params modify; 502}; 503 504/* 505 * LUN request interface: 506 * 507 * backend: This is required, and is NUL-terminated a string 508 * that is the name of the backend, like "ramdisk" or 509 * "block". 510 * 511 * reqtype: The type of request, CTL_LUNREQ_CREATE to create a 512 * LUN, CTL_LUNREQ_RM to delete a LUN. 513 * 514 * reqdata: Request type-specific information. See the 515 * description of individual the union members above 516 * for more information. 517 * 518 * num_be_args: This is the number of backend-specific arguments 519 * in the be_args array. 520 * 521 * be_args: This is an array of backend-specific arguments. 522 * See above for a description of the fields in this 523 * structure. 524 * 525 * status: Status of the LUN request. 526 * 527 * error_str: If the status is CTL_LUN_ERROR, this will 528 * contain a string describing the error. 529 * 530 * kern_be_args: For kernel use only. 531 */ 532struct ctl_lun_req { 533 char backend[CTL_BE_NAME_LEN]; 534 ctl_lunreq_type reqtype; 535 union ctl_lunreq_data reqdata; 536 int num_be_args; 537 struct ctl_be_arg *be_args; 538 ctl_lun_status status; 539 char error_str[CTL_ERROR_STR_LEN]; 540 struct ctl_be_arg *kern_be_args; 541}; 542 543/* 544 * LUN list status: 545 * 546 * NONE: No status. 547 * 548 * OK: Request completed successfully. 549 * 550 * NEED_MORE_SPACE: The allocated length of the entries field is too 551 * small for the available data. 552 * 553 * ERROR: An error occured, look at the error string for a 554 * description of the error. 555 */ 556typedef enum { 557 CTL_LUN_LIST_NONE, 558 CTL_LUN_LIST_OK, 559 CTL_LUN_LIST_NEED_MORE_SPACE, 560 CTL_LUN_LIST_ERROR 561} ctl_lun_list_status; 562 563/* 564 * LUN list interface 565 * 566 * backend_name: This is a NUL-terminated string. If the string 567 * length is 0, then all LUNs on all backends will 568 * be enumerated. Otherwise this is the name of the 569 * backend to be enumerated, like "ramdisk" or "block". 570 * 571 * alloc_len: The length of the data buffer allocated for entries. 572 * In order to properly size the buffer, make one call 573 * with alloc_len set to 0, and then use the returned 574 * dropped_len as the buffer length to allocate and 575 * pass in on a subsequent call. 576 * 577 * lun_xml: XML-formatted information on the requested LUNs. 578 * 579 * fill_len: The amount of data filled in the storage for entries. 580 * 581 * status: The status of the request. See above for the 582 * description of the values of this field. 583 * 584 * error_str: If the status indicates an error, this string will 585 * be filled in to describe the error. 586 */ 587struct ctl_lun_list { 588 char backend[CTL_BE_NAME_LEN]; /* passed to kernel*/ 589 uint32_t alloc_len; /* passed to kernel */ 590 char *lun_xml; /* filled in kernel */ 591 uint32_t fill_len; /* passed to userland */ 592 ctl_lun_list_status status; /* passed to userland */ 593 char error_str[CTL_ERROR_STR_LEN]; 594 /* passed to userland */ 595}; 596 597/* 598 * iSCSI status 599 * 600 * OK: Request completed successfully. 601 * 602 * ERROR: An error occured, look at the error string for a 603 * description of the error. 604 * 605 * CTL_ISCSI_LIST_NEED_MORE_SPACE: 606 * User has to pass larger buffer for CTL_ISCSI_LIST ioctl. 607 */ 608typedef enum { 609 CTL_ISCSI_OK, 610 CTL_ISCSI_ERROR, 611 CTL_ISCSI_LIST_NEED_MORE_SPACE, 612 CTL_ISCSI_SESSION_NOT_FOUND 613} ctl_iscsi_status; 614 615typedef enum { 616 CTL_ISCSI_HANDOFF, 617 CTL_ISCSI_LIST, 618 CTL_ISCSI_LOGOUT, 619 CTL_ISCSI_TERMINATE, 620#if defined(ICL_KERNEL_PROXY) || 1 621 /* 622 * We actually need those in all cases, but leave the ICL_KERNEL_PROXY, 623 * to remember to remove them along with rest of proxy code, eventually. 624 */ 625 CTL_ISCSI_LISTEN, 626 CTL_ISCSI_ACCEPT, 627 CTL_ISCSI_SEND, 628 CTL_ISCSI_RECEIVE, 629#endif 630} ctl_iscsi_type; 631 632typedef enum { 633 CTL_ISCSI_DIGEST_NONE, 634 CTL_ISCSI_DIGEST_CRC32C 635} ctl_iscsi_digest; 636 637#define CTL_ISCSI_NAME_LEN 224 /* 223 bytes, by RFC 3720, + '\0' */ 638#define CTL_ISCSI_ADDR_LEN 47 /* INET6_ADDRSTRLEN + '\0' */ 639#define CTL_ISCSI_ALIAS_LEN 128 /* Arbitrary. */ 640 641struct ctl_iscsi_handoff_params { 642 char initiator_name[CTL_ISCSI_NAME_LEN]; 643 char initiator_addr[CTL_ISCSI_ADDR_LEN]; 644 char initiator_alias[CTL_ISCSI_ALIAS_LEN]; 645 char target_name[CTL_ISCSI_NAME_LEN]; 646 int socket; 647 int portal_group_tag; 648 649 /* 650 * Connection parameters negotiated by ctld(8). 651 */ 652 ctl_iscsi_digest header_digest; 653 ctl_iscsi_digest data_digest; 654 uint32_t cmdsn; 655 uint32_t statsn; 656 uint32_t max_recv_data_segment_length; 657 uint32_t max_burst_length; 658 uint32_t first_burst_length; 659 uint32_t immediate_data; 660#ifdef ICL_KERNEL_PROXY 661 int connection_id; 662 int spare[3]; 663#else 664 int spare[4]; 665#endif 666}; 667 668struct ctl_iscsi_list_params { 669 uint32_t alloc_len; /* passed to kernel */ 670 char *conn_xml; /* filled in kernel */ 671 uint32_t fill_len; /* passed to userland */ 672 int spare[4]; 673}; 674 675struct ctl_iscsi_logout_params { 676 int connection_id; /* passed to kernel */ 677 char initiator_name[CTL_ISCSI_NAME_LEN]; 678 /* passed to kernel */ 679 char initiator_addr[CTL_ISCSI_ADDR_LEN]; 680 /* passed to kernel */ 681 int all; /* passed to kernel */ 682 int spare[4]; 683}; 684 685struct ctl_iscsi_terminate_params { 686 int connection_id; /* passed to kernel */ 687 char initiator_name[CTL_ISCSI_NAME_LEN]; 688 /* passed to kernel */ 689 char initiator_addr[CTL_ISCSI_NAME_LEN]; 690 /* passed to kernel */ 691 int all; /* passed to kernel */ 692 int spare[4]; 693}; 694 695#ifdef ICL_KERNEL_PROXY 696struct ctl_iscsi_listen_params { 697 int iser; 698 int domain; 699 int socktype; 700 int protocol; 701 struct sockaddr *addr; 702 socklen_t addrlen; 703 int portal_id; 704 int spare[4]; 705}; 706 707struct ctl_iscsi_accept_params { 708 int connection_id; 709 struct sockaddr *initiator_addr; 710 int portal_id; 711 int spare[4]; 712}; 713 714struct ctl_iscsi_send_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 724struct ctl_iscsi_receive_params { 725 int connection_id; 726 void *bhs; 727 size_t spare; 728 void *spare2; 729 size_t data_segment_len; 730 void *data_segment; 731 int spare3[4]; 732}; 733 734#endif /* ICL_KERNEL_PROXY */ 735 736union ctl_iscsi_data { 737 struct ctl_iscsi_handoff_params handoff; 738 struct ctl_iscsi_list_params list; 739 struct ctl_iscsi_logout_params logout; 740 struct ctl_iscsi_terminate_params terminate; 741#ifdef ICL_KERNEL_PROXY 742 struct ctl_iscsi_listen_params listen; 743 struct ctl_iscsi_accept_params accept; 744 struct ctl_iscsi_send_params send; 745 struct ctl_iscsi_receive_params receive; 746#endif 747}; 748 749/* 750 * iSCSI interface 751 * 752 * status: The status of the request. See above for the 753 * description of the values of this field. 754 * 755 * error_str: If the status indicates an error, this string will 756 * be filled in to describe the error. 757 */ 758struct ctl_iscsi { 759 ctl_iscsi_type type; /* passed to kernel */ 760 union ctl_iscsi_data data; /* passed to kernel */ 761 ctl_iscsi_status status; /* passed to userland */ 762 char error_str[CTL_ERROR_STR_LEN]; 763 /* passed to userland */ 764}; 765 766#define CTL_IO _IOWR(CTL_MINOR, 0x00, union ctl_io) 767#define CTL_ENABLE_PORT _IOW(CTL_MINOR, 0x04, struct ctl_port_entry) 768#define CTL_DISABLE_PORT _IOW(CTL_MINOR, 0x05, struct ctl_port_entry) 769#define CTL_DUMP_OOA _IO(CTL_MINOR, 0x06) 770#define CTL_CHECK_OOA _IOWR(CTL_MINOR, 0x07, struct ctl_ooa_info) 771#define CTL_HARD_STOP _IOR(CTL_MINOR, 0x08, \ 772 struct ctl_hard_startstop_info) 773#define CTL_HARD_START _IOR(CTL_MINOR, 0x09, \ 774 struct ctl_hard_startstop_info) 775#define CTL_DELAY_IO _IOWR(CTL_MINOR, 0x10, struct ctl_io_delay_info) 776#define CTL_REALSYNC_GET _IOR(CTL_MINOR, 0x11, int) 777#define CTL_REALSYNC_SET _IOW(CTL_MINOR, 0x12, int) 778#define CTL_SETSYNC _IOWR(CTL_MINOR, 0x13, struct ctl_sync_info) 779#define CTL_GETSYNC _IOWR(CTL_MINOR, 0x14, struct ctl_sync_info) 780#define CTL_GETSTATS _IOWR(CTL_MINOR, 0x15, struct ctl_stats) 781#define CTL_ERROR_INJECT _IOWR(CTL_MINOR, 0x16, struct ctl_error_desc) 782#define CTL_BBRREAD _IOWR(CTL_MINOR, 0x17, struct ctl_bbrread_info) 783#define CTL_GET_OOA _IOWR(CTL_MINOR, 0x18, struct ctl_ooa) 784#define CTL_DUMP_STRUCTS _IO(CTL_MINOR, 0x19) 785#define CTL_GET_PORT_LIST _IOWR(CTL_MINOR, 0x20, struct ctl_port_list) 786#define CTL_LUN_REQ _IOWR(CTL_MINOR, 0x21, struct ctl_lun_req) 787#define CTL_LUN_LIST _IOWR(CTL_MINOR, 0x22, struct ctl_lun_list) 788#define CTL_ERROR_INJECT_DELETE _IOW(CTL_MINOR, 0x23, struct ctl_error_desc) 789#define CTL_SET_PORT_WWNS _IOW(CTL_MINOR, 0x24, struct ctl_port_entry) 790#define CTL_ISCSI _IOWR(CTL_MINOR, 0x25, struct ctl_iscsi) 791 792#endif /* _CTL_IOCTL_H_ */ 793 794/* 795 * vim: ts=8 796 */ 797