ctl_ioctl.h revision 265509
10Sduke/*- 210835Scoleenp * Copyright (c) 2003 Silicon Graphics International Corp. 30Sduke * Copyright (c) 2011 Spectra Logic Corporation 40Sduke * All rights reserved. 50Sduke * 60Sduke * Redistribution and use in source and binary forms, with or without 70Sduke * modification, are permitted provided that the following conditions 80Sduke * are met: 90Sduke * 1. Redistributions of source code must retain the above copyright 100Sduke * notice, this list of conditions, and the following disclaimer, 110Sduke * without modification. 120Sduke * 2. Redistributions in binary form must reproduce at minimum a disclaimer 130Sduke * substantially similar to the "NO WARRANTY" disclaimer below 140Sduke * ("Disclaimer") and any redistribution must be conditioned upon 150Sduke * including a substantially similar Disclaimer requirement for further 160Sduke * binary redistribution. 170Sduke * 180Sduke * NO WARRANTY 191472Strims * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 201472Strims * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 211472Strims * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 220Sduke * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 230Sduke * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 240Sduke * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 251879Sstefank * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2610835Scoleenp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 276856Szgu * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 286856Szgu * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291879Sstefank * POSSIBILITY OF SUCH DAMAGES. 301879Sstefank * 310Sduke * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_ioctl.h#4 $ 327033Siveresov * $FreeBSD: stable/10/sys/cam/ctl/ctl_ioctl.h 265509 2014-05-07 07:32:45Z trasz $ 337033Siveresov */ 347033Siveresov/* 357286Siveresov * CAM Target Layer ioctl interface. 367286Siveresov * 377033Siveresov * Author: Ken Merry <ken@FreeBSD.org> 387316Siveresov */ 397033Siveresov 407286Siveresov#ifndef _CTL_IOCTL_H_ 417286Siveresov#define _CTL_IOCTL_H_ 427286Siveresov 437286Siveresov#ifdef ICL_KERNEL_PROXY 447286Siveresov#include <sys/socket.h> 457286Siveresov#endif 467286Siveresov 477286Siveresov#include <sys/ioccom.h> 487286Siveresov 497286Siveresov#define CTL_DEFAULT_DEV "/dev/cam/ctl" 507286Siveresov/* 517286Siveresov * Maximum number of targets we support. 527286Siveresov */ 537286Siveresov#define CTL_MAX_TARGETS 1 547033Siveresov 557286Siveresov/* 567286Siveresov * Maximum target ID we support. 577286Siveresov */ 587286Siveresov#define CTL_MAX_TARGID 15 597286Siveresov 607286Siveresov/* 617286Siveresov * Maximum number of LUNs we support at the moment. MUST be a power of 2. 627286Siveresov */ 637286Siveresov#define CTL_MAX_LUNS 256 647286Siveresov 657286Siveresov/* 667286Siveresov * Maximum number of initiators per port. 677286Siveresov */ 687286Siveresov#define CTL_MAX_INIT_PER_PORT 2048 // Was 16 697286Siveresov 707286Siveresov/* 717286Siveresov * Maximum number of ports registered at one time. 727033Siveresov */ 737033Siveresov#define CTL_MAX_PORTS 32 747286Siveresov 757033Siveresov/* 767033Siveresov * Maximum number of initiators we support. 777286Siveresov */ 787286Siveresov#define CTL_MAX_INITIATORS (CTL_MAX_INIT_PER_PORT * CTL_MAX_PORTS) 797033Siveresov 807033Siveresov/* Hopefully this won't conflict with new misc devices that pop up */ 817033Siveresov#define CTL_MINOR 225 827033Siveresov 837033Siveresovtypedef enum { 847033Siveresov CTL_OOA_INVALID_LUN, 857033Siveresov CTL_OOA_SUCCESS 867033Siveresov} ctl_ooa_status; 877033Siveresov 887286Siveresovstruct ctl_ooa_info { 897033Siveresov uint32_t target_id; /* Passed in to CTL */ 907033Siveresov uint32_t lun_id; /* Passed in to CTL */ 917033Siveresov uint32_t num_entries; /* Returned from CTL */ 927033Siveresov ctl_ooa_status status; /* Returned from CTL */ 937033Siveresov}; 947286Siveresov 957033Siveresovstruct ctl_hard_startstop_info { 967033Siveresov cfi_mt_status status; 977033Siveresov int total_luns; 987033Siveresov int luns_complete; 997033Siveresov int luns_failed; 1007033Siveresov}; 1017033Siveresov 1027033Siveresovstruct ctl_bbrread_info { 1037033Siveresov int lun_num; /* Passed in to CTL */ 1047033Siveresov uint64_t lba; /* Passed in to CTL */ 1057033Siveresov int len; /* Passed in to CTL */ 1067033Siveresov cfi_mt_status status; /* Returned from CTL */ 1077033Siveresov cfi_bbrread_status bbr_status; /* Returned from CTL */ 1087286Siveresov uint8_t scsi_status; /* Returned from CTL */ 1097033Siveresov struct scsi_sense_data sense_data; /* Returned from CTL */ 1107033Siveresov}; 1117033Siveresov 1127033Siveresovtypedef enum { 1137033Siveresov CTL_DELAY_TYPE_NONE, 1147033Siveresov CTL_DELAY_TYPE_CONT, 1157033Siveresov CTL_DELAY_TYPE_ONESHOT 1167286Siveresov} ctl_delay_type; 1177033Siveresov 1187033Siveresovtypedef enum { 1197033Siveresov CTL_DELAY_LOC_NONE, 1207033Siveresov CTL_DELAY_LOC_DATAMOVE, 1217033Siveresov CTL_DELAY_LOC_DONE, 1227033Siveresov} ctl_delay_location; 1237033Siveresov 1247033Siveresovtypedef enum { 1257033Siveresov CTL_DELAY_STATUS_NONE, 1267033Siveresov CTL_DELAY_STATUS_OK, 1277033Siveresov CTL_DELAY_STATUS_INVALID_LUN, 1287033Siveresov CTL_DELAY_STATUS_INVALID_TYPE, 1297033Siveresov CTL_DELAY_STATUS_INVALID_LOC, 1307033Siveresov CTL_DELAY_STATUS_NOT_IMPLEMENTED 1318202Siveresov} ctl_delay_status; 1327316Siveresov 1337033Siveresovstruct ctl_io_delay_info { 1347316Siveresov uint32_t target_id; 1357316Siveresov uint32_t lun_id; 1367316Siveresov ctl_delay_type delay_type; 1377316Siveresov ctl_delay_location delay_loc; 1387316Siveresov uint32_t delay_secs; 1397033Siveresov ctl_delay_status status; 1408202Siveresov}; 1417033Siveresov 1428202Siveresovtypedef enum { 1437316Siveresov CTL_GS_SYNC_NONE, 1447316Siveresov CTL_GS_SYNC_OK, 1457316Siveresov CTL_GS_SYNC_NO_LUN 1467316Siveresov} ctl_gs_sync_status; 1477316Siveresov 1487316Siveresov/* 1497316Siveresov * The target and LUN id specify which device to modify. The sync interval 1507316Siveresov * means that we will let through every N SYNCHRONIZE CACHE commands. 1517316Siveresov */ 1527316Siveresovstruct ctl_sync_info { 1537316Siveresov uint32_t target_id; /* passed to kernel */ 1547316Siveresov uint32_t lun_id; /* passed to kernel */ 1557316Siveresov int sync_interval; /* depends on whether get/set */ 1567316Siveresov ctl_gs_sync_status status; /* passed from kernel */ 1577316Siveresov}; 1587316Siveresov 1598202Siveresovtypedef enum { 1608202Siveresov CTL_STATS_NO_IO, 1618202Siveresov CTL_STATS_READ, 1628202Siveresov CTL_STATS_WRITE 1638202Siveresov} ctl_stat_types; 1648202Siveresov#define CTL_STATS_NUM_TYPES 3 1658202Siveresov 1668202Siveresovtypedef enum { 1678202Siveresov CTL_LUN_STATS_NO_BLOCKSIZE = 0x01 1688202Siveresov} ctl_lun_stats_flags; 1698202Siveresov 1708202Siveresovstruct ctl_lun_io_port_stats { 1718202Siveresov uint32_t targ_port; 1727316Siveresov uint64_t bytes[CTL_STATS_NUM_TYPES]; 1737316Siveresov uint64_t operations[CTL_STATS_NUM_TYPES]; 1747316Siveresov struct bintime time[CTL_STATS_NUM_TYPES]; 1757316Siveresov uint64_t num_dmas[CTL_STATS_NUM_TYPES]; 1767316Siveresov struct bintime dma_time[CTL_STATS_NUM_TYPES]; 1777316Siveresov}; 1787316Siveresov 1797033Siveresovstruct ctl_lun_io_stats { 1807033Siveresov uint8_t device_type; 1817033Siveresov uint64_t lun_number; 1827033Siveresov uint32_t blocksize; 1837316Siveresov ctl_lun_stats_flags flags; 1847316Siveresov struct ctl_lun_io_port_stats ports[CTL_MAX_PORTS]; 1857033Siveresov}; 1867033Siveresov 1878202Siveresovtypedef enum { 1887033Siveresov CTL_SS_OK, 1897316Siveresov CTL_SS_NEED_MORE_SPACE, 1907316Siveresov CTL_SS_ERROR 1917033Siveresov} ctl_stats_status; 1927033Siveresov 1938631Siveresovtypedef enum { 1947286Siveresov CTL_STATS_FLAG_NONE = 0x00, 1957286Siveresov CTL_STATS_FLAG_TIME_VALID = 0x01 1967286Siveresov} ctl_stats_flags; 1977286Siveresov 1987033Siveresovstruct ctl_stats { 1997286Siveresov int alloc_len; /* passed to kernel */ 2007316Siveresov struct ctl_lun_io_stats *lun_stats; /* passed to/from kernel */ 2017316Siveresov int fill_len; /* passed to userland */ 2027316Siveresov int num_luns; /* passed to userland */ 2037316Siveresov ctl_stats_status status; /* passed to userland */ 2047033Siveresov ctl_stats_flags flags; /* passed to userland */ 2058631Siveresov struct timespec timestamp; /* passed to userland */ 2067316Siveresov}; 2077316Siveresov 2087316Siveresov/* 2097033Siveresov * The types of errors that can be injected: 2107316Siveresov * 2118202Siveresov * NONE: No error specified. 2127033Siveresov * ABORTED: SSD_KEY_ABORTED_COMMAND, 0x45, 0x00 2137033Siveresov * MEDIUM_ERR: Medium error, different asc/ascq depending on read/write. 2147286Siveresov * UA: Unit attention. 2157033Siveresov * CUSTOM: User specifies the sense data. 2167286Siveresov * TYPE: Mask to use with error types. 2177033Siveresov * 2187033Siveresov * Flags that affect injection behavior: 2197033Siveresov * CONTINUOUS: This error will stay around until explicitly cleared. 2208202Siveresov * DESCRIPTOR: Use descriptor sense instead of fixed sense. 2217033Siveresov */ 2227033Siveresovtypedef enum { 2237316Siveresov CTL_LUN_INJ_NONE = 0x000, 2247316Siveresov CTL_LUN_INJ_ABORTED = 0x001, 2257316Siveresov CTL_LUN_INJ_MEDIUM_ERR = 0x002, 2267033Siveresov CTL_LUN_INJ_UA = 0x003, 2270Sduke CTL_LUN_INJ_CUSTOM = 0x004, 2287286Siveresov CTL_LUN_INJ_TYPE = 0x0ff, 2297286Siveresov CTL_LUN_INJ_CONTINUOUS = 0x100, 2307286Siveresov CTL_LUN_INJ_DESCRIPTOR = 0x200 2317286Siveresov} ctl_lun_error; 2327286Siveresov 2337286Siveresov/* 2347286Siveresov * Flags to specify what type of command the given error pattern will 2357286Siveresov * execute on. The first group of types can be ORed together. 2367286Siveresov * 2377286Siveresov * READ: Any read command. 2387286Siveresov * WRITE: Any write command. 2397286Siveresov * READWRITE: Any read or write command. 2407286Siveresov * READCAP: Any read capacity command. 2417286Siveresov * TUR: Test Unit Ready. 2427286Siveresov * ANY: Any command. 2437286Siveresov * MASK: Mask for basic command patterns. 2447286Siveresov * 2457286Siveresov * Special types: 2467286Siveresov * 2477286Siveresov * CMD: The CDB to act on is specified in struct ctl_error_desc_cmd. 2487286Siveresov * RANGE: For read/write commands, act when the LBA is in the 2497286Siveresov * specified range. 2507286Siveresov */ 2517286Siveresovtypedef enum { 2527286Siveresov CTL_LUN_PAT_NONE = 0x000, 2537286Siveresov CTL_LUN_PAT_READ = 0x001, 2547286Siveresov CTL_LUN_PAT_WRITE = 0x002, 2557286Siveresov CTL_LUN_PAT_READWRITE = CTL_LUN_PAT_READ | CTL_LUN_PAT_WRITE, 2567286Siveresov CTL_LUN_PAT_READCAP = 0x004, 2577286Siveresov CTL_LUN_PAT_TUR = 0x008, 2587286Siveresov CTL_LUN_PAT_ANY = 0x0ff, 2597286Siveresov CTL_LUN_PAT_MASK = 0x0ff, 2607286Siveresov CTL_LUN_PAT_CMD = 0x100, 2617286Siveresov CTL_LUN_PAT_RANGE = 0x200 2627286Siveresov} ctl_lun_error_pattern; 2637286Siveresov 26410358Siveresov/* 26510358Siveresov * This structure allows the user to specify a particular CDB pattern to 26610358Siveresov * look for. 26710358Siveresov * 26810358Siveresov * cdb_pattern: Fill in the relevant bytes to look for in the CDB. 26910358Siveresov * cdb_valid_bytes: Bitmask specifying valid bytes in the cdb_pattern. 270641Stwisti * flags: Specify any command flags (see ctl_io_flags) that 27110358Siveresov * should be set. 27210358Siveresov */ 27310358Siveresovstruct ctl_error_desc_cmd { 27410358Siveresov uint8_t cdb_pattern[CTL_MAX_CDBLEN]; 27510358Siveresov uint32_t cdb_valid_bytes; 27610358Siveresov uint32_t flags; 27710358Siveresov}; 27810358Siveresov 27910358Siveresov/* 28010358Siveresov * Error injection descriptor. 28110358Siveresov * 282641Stwisti * target_id: Target ID to act on. 28310358Siveresov * lun_id LUN to act on. 28410358Siveresov * lun_error: The type of error to inject. See above for descriptions. 28510358Siveresov * error_pattern: What kind of command to act on. See above. 286641Stwisti * cmd_desc: For CTL_LUN_PAT_CMD only. 287641Stwisti * lba_range: For CTL_LUN_PAT_RANGE only. 288641Stwisti * custom_sense: Specify sense. For CTL_LUN_INJ_CUSTOM only. 28910358Siveresov * serial: Serial number returned by the kernel. Use for deletion. 29010358Siveresov * links: Kernel use only. 29110358Siveresov */ 29210358Siveresovstruct ctl_error_desc { 29310358Siveresov uint32_t target_id; /* To kernel */ 29410358Siveresov uint32_t lun_id; /* To kernel */ 29510358Siveresov ctl_lun_error lun_error; /* To kernel */ 29610358Siveresov ctl_lun_error_pattern error_pattern; /* To kernel */ 29710358Siveresov struct ctl_error_desc_cmd cmd_desc; /* To kernel */ 29810358Siveresov struct ctl_lba_len lba_range; /* To kernel */ 29910358Siveresov struct scsi_sense_data custom_sense; /* To kernel */ 30010358Siveresov uint64_t serial; /* From kernel */ 30110358Siveresov STAILQ_ENTRY(ctl_error_desc) links; /* Kernel use only */ 30210358Siveresov}; 30310358Siveresov 30410358Siveresovtypedef enum { 30510358Siveresov CTL_OOA_FLAG_NONE = 0x00, 30610358Siveresov CTL_OOA_FLAG_ALL_LUNS = 0x01 30710358Siveresov} ctl_ooa_flags; 30810358Siveresov 30910358Siveresovtypedef enum { 31010358Siveresov CTL_OOA_OK, 31110358Siveresov CTL_OOA_NEED_MORE_SPACE, 31210358Siveresov CTL_OOA_ERROR 31310358Siveresov} ctl_get_ooa_status; 31410358Siveresov 31510358Siveresovtypedef enum { 31610358Siveresov CTL_OOACMD_FLAG_NONE = 0x00, 31710358Siveresov CTL_OOACMD_FLAG_DMA = 0x01, 31810358Siveresov CTL_OOACMD_FLAG_BLOCKED = 0x02, 31910358Siveresov CTL_OOACMD_FLAG_ABORT = 0x04, 32010358Siveresov CTL_OOACMD_FLAG_RTR = 0x08, 32110358Siveresov CTL_OOACMD_FLAG_DMA_QUEUED = 0x10 32210358Siveresov} ctl_ooa_cmd_flags; 32310358Siveresov 32410358Siveresovstruct ctl_ooa_entry { 32510358Siveresov ctl_ooa_cmd_flags cmd_flags; 32610358Siveresov uint8_t cdb[CTL_MAX_CDBLEN]; 32710358Siveresov uint8_t cdb_len; 328641Stwisti uint32_t tag_num; 32913216Sneliasso uint32_t lun_num; 33013216Sneliasso struct bintime start_bt; 3310Sduke}; 33213216Sneliasso 333641Stwististruct ctl_ooa { 3346905Sanoll ctl_ooa_flags flags; /* passed to kernel */ 33513216Sneliasso uint64_t lun_num; /* passed to kernel */ 33613216Sneliasso uint32_t alloc_len; /* passed to kernel */ 33713216Sneliasso uint32_t alloc_num; /* passed to kernel */ 3381834Skvn struct ctl_ooa_entry *entries; /* filled in kernel */ 33912160Salanbur uint32_t fill_len; /* passed to userland */ 34012160Salanbur uint32_t fill_num; /* passed to userland */ 34112160Salanbur uint32_t dropped_num; /* passed to userland */ 3426905Sanoll struct bintime cur_bt; /* passed to userland */ 3431834Skvn ctl_get_ooa_status status; /* passed to userland */ 34413216Sneliasso}; 34513216Sneliasso 34613216Sneliassotypedef enum { 34713216Sneliasso CTL_PORT_LIST_NONE, 34813216Sneliasso CTL_PORT_LIST_OK, 34913216Sneliasso CTL_PORT_LIST_NEED_MORE_SPACE, 35013216Sneliasso CTL_PORT_LIST_ERROR 35113216Sneliasso} ctl_port_list_status; 35213216Sneliasso 35313216Sneliassostruct ctl_port_list { 35413216Sneliasso uint32_t alloc_len; /* passed to kernel */ 35513216Sneliasso uint32_t alloc_num; /* passed to kernel */ 35613216Sneliasso struct ctl_port_entry *entries; /* filled in kernel */ 35713216Sneliasso uint32_t fill_len; /* passed to userland */ 35813216Sneliasso uint32_t fill_num; /* passed to userland */ 35913216Sneliasso uint32_t dropped_num; /* passed to userland */ 36013216Sneliasso ctl_port_list_status status; /* passed to userland */ 36113216Sneliasso}; 36213216Sneliasso 36313216Sneliassotypedef enum { 36413216Sneliasso CTL_LUN_NOSTATUS, 36513216Sneliasso CTL_LUN_OK, 36613216Sneliasso CTL_LUN_ERROR 36713216Sneliasso} ctl_lun_status; 36813216Sneliasso 36913216Sneliasso#define CTL_ERROR_STR_LEN 160 37013216Sneliasso 37113216Sneliasso#define CTL_BEARG_RD 0x01 37213216Sneliasso#define CTL_BEARG_WR 0x02 37313216Sneliasso#define CTL_BEARG_RW (CTL_BEARG_RD|CTL_BEARG_WR) 37413216Sneliasso#define CTL_BEARG_ASCII 0x04 37513216Sneliasso 37613216Sneliasso/* 37713216Sneliasso * Backend Argument: 37813216Sneliasso * 37913216Sneliasso * namelen: Length of the name field, including the terminating NUL. 38013216Sneliasso * 3811968Skvn * name: Name of the paramter. This must be NUL-terminated. 38213216Sneliasso * 38313216Sneliasso * flags: Flags for the parameter, see above for values. 38413216Sneliasso * 38513216Sneliasso * vallen: Length of the value in bytes. 38613216Sneliasso * 38713216Sneliasso * value: Value to be set/fetched. 38813216Sneliasso * 38913216Sneliasso * kname: For kernel use only. 39013216Sneliasso * 39113216Sneliasso * kvalue: For kernel use only. 39213216Sneliasso */ 39313216Sneliassostruct ctl_be_arg { 39413216Sneliasso int namelen; 39513216Sneliasso char *name; 39613216Sneliasso int flags; 39713216Sneliasso int vallen; 39813216Sneliasso void *value; 39913216Sneliasso 40013216Sneliasso char *kname; 40113216Sneliasso void *kvalue; 40213216Sneliasso}; 40313216Sneliasso 40413216Sneliassotypedef enum { 40513216Sneliasso CTL_LUNREQ_CREATE, 40613216Sneliasso CTL_LUNREQ_RM, 40713216Sneliasso CTL_LUNREQ_MODIFY, 40813216Sneliasso} ctl_lunreq_type; 4090Sduke 41013216Sneliasso 41113216Sneliasso/* 41213216Sneliasso * LUN creation parameters: 41313216Sneliasso * 41413216Sneliasso * flags: Various LUN flags, see ctl_backend.h for a 41513216Sneliasso * description of the flag values and meanings. 41613216Sneliasso * 41713216Sneliasso * device_type: The SCSI device type. e.g. 0 for Direct Access, 41813216Sneliasso * 3 for Processor, etc. Only certain backends may 41913216Sneliasso * support setting this field. The CTL_LUN_FLAG_DEV_TYPE 42013216Sneliasso * flag should be set in the flags field if the device 42113216Sneliasso * type is set. 42210358Siveresov * 4230Sduke * lun_size_bytes: The size of the LUN in bytes. For some backends 42413216Sneliasso * this is relevant (e.g. ramdisk), for others, it may 42513216Sneliasso * be ignored in favor of using the properties of the 42613216Sneliasso * backing store. If specified, this should be a 42713216Sneliasso * multiple of the blocksize. 42813216Sneliasso * 42913216Sneliasso * The actual size of the LUN is returned in this 43013216Sneliasso * field. 43113216Sneliasso * 43213216Sneliasso * blocksize_bytes: The LUN blocksize in bytes. For some backends this 43313216Sneliasso * is relevant, for others it may be ignored in 43413216Sneliasso * favor of using the properties of the backing store. 43513216Sneliasso * 43613216Sneliasso * The actual blocksize of the LUN is returned in this 43713216Sneliasso * field. 43813216Sneliasso * 43913216Sneliasso * req_lun_id: The requested LUN ID. The CTL_LUN_FLAG_ID_REQ flag 44013216Sneliasso * should be set if this is set. The request will be 44113216Sneliasso * granted if the LUN number is available, otherwise 44213216Sneliasso * the LUN addition request will fail. 44313216Sneliasso * 44413216Sneliasso * The allocated LUN number is returned in this field. 44513216Sneliasso * 44613216Sneliasso * serial_num: This is the value returned in SCSI INQUIRY VPD page 44713216Sneliasso * 0x80. If it is specified, the CTL_LUN_FLAG_SERIAL_NUM 44813216Sneliasso * flag should be set. 44913216Sneliasso * 45013216Sneliasso * The serial number value used is returned in this 45113216Sneliasso * field. 45213216Sneliasso * 45313216Sneliasso * device_id: This is the value returned in the T10 vendor ID 45413216Sneliasso * based DESIGNATOR field in the SCSI INQUIRY VPD page 45513216Sneliasso * 0x83 data. If it is specified, the CTL_LUN_FLAG_DEVID 45613216Sneliasso * flag should be set. 45713216Sneliasso * 45813216Sneliasso * The device id value used is returned in this field. 45913216Sneliasso */ 46010358Siveresovstruct ctl_lun_create_params { 46113216Sneliasso ctl_backend_lun_flags flags; 4621968Skvn uint8_t device_type; 46313216Sneliasso uint64_t lun_size_bytes; 46413216Sneliasso uint32_t blocksize_bytes; 46513216Sneliasso uint32_t req_lun_id; 46613216Sneliasso uint8_t serial_num[CTL_SN_LEN]; 46713216Sneliasso uint8_t device_id[CTL_DEVID_LEN]; 46813216Sneliasso}; 46913216Sneliasso 4701968Skvn/* 47113216Sneliasso * LUN removal parameters: 47213216Sneliasso * 47313216Sneliasso * lun_id: The number of the LUN to delete. This must be set. 47413216Sneliasso * The LUN must be backed by the given backend. 47510358Siveresov */ 47613216Sneliassostruct ctl_lun_rm_params { 47713216Sneliasso uint32_t lun_id; 47810358Siveresov}; 47910358Siveresov 48010358Siveresov/* 4810Sduke * 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