ctl_private.h revision 275895
1192468Ssam/*- 2192468Ssam * Copyright (c) 2003, 2004, 2005, 2008 Silicon Graphics International Corp. 3192468Ssam * All rights reserved. 4192468Ssam * 5192468Ssam * Redistribution and use in source and binary forms, with or without 6192468Ssam * modification, are permitted provided that the following conditions 7192468Ssam * are met: 8192468Ssam * 1. Redistributions of source code must retain the above copyright 9192468Ssam * notice, this list of conditions, and the following disclaimer, 10192468Ssam * without modification. 11192468Ssam * 2. Redistributions in binary form must reproduce at minimum a disclaimer 12192468Ssam * substantially similar to the "NO WARRANTY" disclaimer below 13192468Ssam * ("Disclaimer") and any redistribution must be conditioned upon 14192468Ssam * including a substantially similar Disclaimer requirement for further 15192468Ssam * binary redistribution. 16192468Ssam * 17192468Ssam * NO WARRANTY 18192468Ssam * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19192468Ssam * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20192468Ssam * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 21192468Ssam * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22192468Ssam * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23192468Ssam * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24192468Ssam * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25192468Ssam * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26192468Ssam * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 27192468Ssam * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28192468Ssam * POSSIBILITY OF SUCH DAMAGES. 29192468Ssam * 30192468Ssam * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_private.h#7 $ 31192468Ssam * $FreeBSD: stable/10/sys/cam/ctl/ctl_private.h 275895 2014-12-18 08:46:53Z mav $ 32192468Ssam */ 33192468Ssam/* 34192468Ssam * CAM Target Layer driver private data structures/definitions. 35192468Ssam * 36192468Ssam * Author: Ken Merry <ken@FreeBSD.org> 37192468Ssam */ 38192468Ssam 39192468Ssam#ifndef _CTL_PRIVATE_H_ 40192468Ssam#define _CTL_PRIVATE_H_ 41192468Ssam 42192468Ssam/* 43192468Ssam * SCSI vendor and product names. 44192468Ssam */ 45192468Ssam#define CTL_VENDOR "FREEBSD " 46192468Ssam#define CTL_DIRECT_PRODUCT "CTLDISK " 47192468Ssam#define CTL_PROCESSOR_PRODUCT "CTLPROCESSOR " 48192468Ssam#define CTL_UNKNOWN_PRODUCT "CTLDEVICE " 49192468Ssam 50237214Sadrianstruct ctl_fe_ioctl_startstop_info { 51192468Ssam struct cv sem; 52192468Ssam struct ctl_hard_startstop_info hs_info; 53192468Ssam}; 54192468Ssam 55192468Ssamstruct ctl_fe_ioctl_bbrread_info { 56192468Ssam struct cv sem; 57237214Sadrian struct ctl_bbrread_info *bbr_info; 58237214Sadrian int wakeup_done; 59237214Sadrian struct mtx *lock; 60237214Sadrian}; 61237214Sadrian 62237214Sadriantypedef enum { 63237214Sadrian CTL_IOCTL_INPROG, 64237214Sadrian CTL_IOCTL_DATAMOVE, 65237214Sadrian CTL_IOCTL_DONE 66237214Sadrian} ctl_fe_ioctl_state; 67237214Sadrian 68192468Ssamstruct ctl_fe_ioctl_params { 69192468Ssam struct cv sem; 70192468Ssam struct mtx ioctl_mtx; 71192468Ssam ctl_fe_ioctl_state state; 72192468Ssam}; 73192468Ssam 74192468Ssam#define CTL_POOL_ENTRIES_OTHER_SC 200 75192468Ssam 76192468Ssamstruct ctl_io_pool { 77237214Sadrian char name[64]; 78192468Ssam uint32_t id; 79237214Sadrian struct ctl_softc *ctl_softc; 80192468Ssam struct uma_zone *zone; 81232705Sadrian}; 82192468Ssam 83192468Ssamtypedef enum { 84192468Ssam CTL_IOCTL_FLAG_NONE = 0x00, 85192468Ssam CTL_IOCTL_FLAG_ENABLED = 0x01 86192468Ssam} ctl_ioctl_flags; 87192468Ssam 88192468Ssamstruct ctl_ioctl_info { 89192468Ssam ctl_ioctl_flags flags; 90192468Ssam uint32_t cur_tag_num; 91192468Ssam struct ctl_port port; 92192468Ssam char port_name[24]; 93237214Sadrian}; 94192468Ssam 95237214Sadriantypedef enum { 96192468Ssam CTL_SER_BLOCK, 97232705Sadrian CTL_SER_BLOCKOPT, 98192468Ssam CTL_SER_EXTENT, 99192468Ssam CTL_SER_EXTENTOPT, 100192468Ssam CTL_SER_EXTENTSEQ, 101192468Ssam CTL_SER_PASS, 102192468Ssam CTL_SER_SKIP 103192468Ssam} ctl_serialize_action; 104192468Ssam 105192468Ssamtypedef enum { 106192468Ssam CTL_ACTION_BLOCK, 107192468Ssam CTL_ACTION_OVERLAP, 108192468Ssam CTL_ACTION_OVERLAP_TAG, 109192468Ssam CTL_ACTION_PASS, 110192468Ssam CTL_ACTION_SKIP, 111192468Ssam CTL_ACTION_ERROR 112192468Ssam} ctl_action; 113192468Ssam 114192468Ssam/* 115192468Ssam * WARNING: Keep the bottom nibble here free, we OR in the data direction 116192765Ssam * flags for each command. 117192765Ssam * 118192765Ssam * Note: "OK_ON_ALL_LUNS" == we don't have to have a lun configured 119192765Ssam * "OK_ON_BOTH" == we have to have a lun configured 120192765Ssam * "SA5" == command has 5-bit service action at byte 1 121192765Ssam */ 122192468Ssamtypedef enum { 123192468Ssam CTL_CMD_FLAG_NONE = 0x0000, 124192468Ssam CTL_CMD_FLAG_NO_SENSE = 0x0010, 125192468Ssam CTL_CMD_FLAG_OK_ON_ALL_LUNS = 0x0020, 126192468Ssam CTL_CMD_FLAG_ALLOW_ON_RESV = 0x0040, 127192468Ssam CTL_CMD_FLAG_ALLOW_ON_PR_WRESV = 0x0080, 128192468Ssam CTL_CMD_FLAG_OK_ON_PROC = 0x0100, 129192468Ssam CTL_CMD_FLAG_OK_ON_SLUN = 0x0200, 130192468Ssam CTL_CMD_FLAG_OK_ON_BOTH = 0x0300, 131192468Ssam CTL_CMD_FLAG_OK_ON_STOPPED = 0x0400, 132192468Ssam CTL_CMD_FLAG_OK_ON_INOPERABLE = 0x0800, 133192468Ssam CTL_CMD_FLAG_OK_ON_OFFLINE = 0x1000, 134192468Ssam CTL_CMD_FLAG_OK_ON_SECONDARY = 0x2000, 135192468Ssam CTL_CMD_FLAG_ALLOW_ON_PR_RESV = 0x4000, 136192468Ssam CTL_CMD_FLAG_SA5 = 0x8000 137192468Ssam} ctl_cmd_flags; 138192468Ssam 139192468Ssamtypedef enum { 140192468Ssam CTL_SERIDX_TUR = 0, 141192468Ssam CTL_SERIDX_READ, 142192468Ssam CTL_SERIDX_WRITE, 143192468Ssam CTL_SERIDX_UNMAP, 144192468Ssam CTL_SERIDX_MD_SNS, 145192468Ssam CTL_SERIDX_MD_SEL, 146192468Ssam CTL_SERIDX_RQ_SNS, 147192468Ssam CTL_SERIDX_INQ, 148192468Ssam CTL_SERIDX_RD_CAP, 149192468Ssam CTL_SERIDX_RES, 150192468Ssam CTL_SERIDX_LOG_SNS, 151192468Ssam CTL_SERIDX_FORMAT, 152192468Ssam CTL_SERIDX_START, 153192468Ssam /* TBD: others to be filled in as needed */ 154192468Ssam CTL_SERIDX_COUNT, /* LAST, not a normal code, provides # codes */ 155192468Ssam CTL_SERIDX_INVLD = CTL_SERIDX_COUNT 156192468Ssam} ctl_seridx; 157192468Ssam 158192468Ssamtypedef int ctl_opfunc(struct ctl_scsiio *ctsio); 159192468Ssam 160192468Ssamstruct ctl_cmd_entry { 161192468Ssam ctl_opfunc *execute; 162192468Ssam ctl_seridx seridx; 163192468Ssam ctl_cmd_flags flags; 164192468Ssam ctl_lun_error_pattern pattern; 165192468Ssam uint8_t length; /* CDB length */ 166192468Ssam uint8_t usage[15]; /* Mask of allowed CDB bits 167193760Ssam * after the opcode byte. */ 168192468Ssam}; 169193760Ssam 170192468Ssamtypedef enum { 171192468Ssam CTL_LUN_NONE = 0x000, 172192468Ssam CTL_LUN_CONTROL = 0x001, 173192468Ssam CTL_LUN_RESERVED = 0x002, 174192468Ssam CTL_LUN_INVALID = 0x004, 175193760Ssam CTL_LUN_DISABLED = 0x008, 176192468Ssam CTL_LUN_MALLOCED = 0x010, 177193760Ssam CTL_LUN_STOPPED = 0x020, 178192468Ssam CTL_LUN_INOPERABLE = 0x040, 179192468Ssam CTL_LUN_OFFLINE = 0x080, 180192468Ssam CTL_LUN_PR_RESERVED = 0x100, 181192468Ssam CTL_LUN_PRIMARY_SC = 0x200, 182192468Ssam CTL_LUN_SENSE_DESC = 0x400, 183193292Ssam CTL_LUN_READONLY = 0x800 184193292Ssam} ctl_lun_flags; 185193292Ssam 186193292Ssamtypedef enum { 187193292Ssam CTL_LUN_SERSEQ_OFF, 188193292Ssam CTL_LUN_SERSEQ_READ, 189193292Ssam CTL_LUN_SERSEQ_ON 190193292Ssam} ctl_lun_serseq; 191193292Ssam 192193292Ssamtypedef enum { 193193292Ssam CTLBLOCK_FLAG_NONE = 0x00, 194193292Ssam CTLBLOCK_FLAG_INVALID = 0x01 195193292Ssam} ctlblock_flags; 196193292Ssam 197193292Ssamunion ctl_softcs { 198193292Ssam struct ctl_softc *ctl_softc; 199193292Ssam struct ctlblock_softc *ctlblock_softc; 200193292Ssam}; 201193292Ssam 202193292Ssam/* 203192468Ssam * Mode page defaults. 204192468Ssam */ 205192468Ssam#if 0 206192468Ssam/* 207192468Ssam * These values make Solaris trim off some of the capacity. 208193292Ssam */ 209193292Ssam#define CTL_DEFAULT_SECTORS_PER_TRACK 63 210193292Ssam#define CTL_DEFAULT_HEADS 255 211193292Ssam/* 212193292Ssam * These values seem to work okay. 213193292Ssam */ 214193292Ssam#define CTL_DEFAULT_SECTORS_PER_TRACK 63 215193292Ssam#define CTL_DEFAULT_HEADS 16 216193292Ssam/* 217193292Ssam * These values work reasonably well. 218193292Ssam */ 219193292Ssam#define CTL_DEFAULT_SECTORS_PER_TRACK 512 220193292Ssam#define CTL_DEFAULT_HEADS 64 221193292Ssam#endif 222192468Ssam 223192468Ssam/* 224192468Ssam * Solaris is somewhat picky about how many heads and sectors per track you 225192468Ssam * have defined in mode pages 3 and 4. These values seem to cause Solaris 226192468Ssam * to get the capacity more or less right when you run the format tool. 227192468Ssam * They still have problems when dealing with devices larger than 1TB, 228192468Ssam * but there isn't anything we can do about that. 229192468Ssam * 230193292Ssam * For smaller LUN sizes, this ends up causing the number of cylinders to 231193292Ssam * work out to 0. Solaris actually recognizes that and comes up with its 232193292Ssam * own bogus geometry to fit the actual capacity of the drive. They really 233193292Ssam * should just give up on geometry and stick to the read capacity 234193292Ssam * information alone for modern disk drives. 235193292Ssam * 236193292Ssam * One thing worth mentioning about Solaris' mkfs command is that it 237193292Ssam * doesn't like sectors per track values larger than 256. 512 seems to 238193292Ssam * work okay for format, but causes problems when you try to make a 239193292Ssam * filesystem. 240193292Ssam * 241193292Ssam * Another caveat about these values: the product of these two values 242193292Ssam * really should be a power of 2. This is because of the simplistic 243193292Ssam * shift-based calculation that we have to use on the i386 platform to 244193292Ssam * calculate the number of cylinders here. (If you use a divide, you end 245193292Ssam * up calling __udivdi3(), which is a hardware FP call on the PC. On the 246192468Ssam * XScale, it is done in software, so you can do that from inside the 247192468Ssam * kernel.) 248192468Ssam * 249192468Ssam * So for the current values (256 S/T, 128 H), we get 32768, which works 250192468Ssam * very nicely for calculating cylinders. 251192468Ssam * 252192468Ssam * If you want to change these values so that their product is no longer a 253192468Ssam * power of 2, re-visit the calculation in ctl_init_page_index(). You may 254192468Ssam * need to make it a bit more complicated to get the number of cylinders 255192468Ssam * right. 256192468Ssam */ 257192468Ssam#define CTL_DEFAULT_SECTORS_PER_TRACK 256 258192468Ssam#define CTL_DEFAULT_HEADS 128 259192468Ssam 260192468Ssam#define CTL_DEFAULT_ROTATION_RATE SVPD_NON_ROTATING 261192468Ssam 262193292Ssamstruct ctl_page_index; 263193292Ssam 264192468Ssamtypedef int ctl_modesen_handler(struct ctl_scsiio *ctsio, 265192468Ssam struct ctl_page_index *page_index, 266192468Ssam int pc); 267192468Ssamtypedef int ctl_modesel_handler(struct ctl_scsiio *ctsio, 268192468Ssam struct ctl_page_index *page_index, 269192468Ssam uint8_t *page_ptr); 270192468Ssam 271192468Ssamtypedef enum { 272192468Ssam CTL_PAGE_FLAG_NONE = 0x00, 273192468Ssam CTL_PAGE_FLAG_DISK_ONLY = 0x01 274237214Sadrian} ctl_page_flags; 275237214Sadrian 276192468Ssamstruct ctl_page_index { 277192468Ssam uint8_t page_code; 278192468Ssam uint8_t subpage; 279192468Ssam uint16_t page_len; 280192468Ssam uint8_t *page_data; 281192468Ssam ctl_page_flags page_flags; 282192468Ssam ctl_modesen_handler *sense_handler; 283192468Ssam ctl_modesel_handler *select_handler; 284192468Ssam}; 285192468Ssam 286192468Ssam#define CTL_PAGE_CURRENT 0x00 287192468Ssam#define CTL_PAGE_CHANGEABLE 0x01 288192468Ssam#define CTL_PAGE_DEFAULT 0x02 289192468Ssam#define CTL_PAGE_SAVED 0x03 290192468Ssam 291192468Ssam#define CTL_NUM_LBP_PARAMS 4 292192468Ssam#define CTL_NUM_LBP_THRESH 4 293192468Ssam#define CTL_LBP_EXPONENT 11 /* 2048 sectors */ 294192468Ssam#define CTL_LBP_PERIOD 10 /* 10 seconds */ 295192468Ssam#define CTL_LBP_UA_PERIOD 300 /* 5 minutes */ 296192468Ssam 297192468Ssamstruct ctl_logical_block_provisioning_page { 298192468Ssam struct scsi_logical_block_provisioning_page main; 299192468Ssam struct scsi_logical_block_provisioning_page_descr descr[CTL_NUM_LBP_THRESH]; 300192468Ssam}; 301192468Ssam 302192468Ssamstatic const struct ctl_page_index page_index_template[] = { 303192468Ssam {SMS_RW_ERROR_RECOVERY_PAGE, 0, sizeof(struct scsi_da_rw_recovery_page), NULL, 304192468Ssam CTL_PAGE_FLAG_DISK_ONLY, NULL, NULL}, 305192468Ssam {SMS_FORMAT_DEVICE_PAGE, 0, sizeof(struct scsi_format_page), NULL, 306192468Ssam CTL_PAGE_FLAG_DISK_ONLY, NULL, NULL}, 307192468Ssam {SMS_RIGID_DISK_PAGE, 0, sizeof(struct scsi_rigid_disk_page), NULL, 308192468Ssam CTL_PAGE_FLAG_DISK_ONLY, NULL, NULL}, 309192468Ssam {SMS_CACHING_PAGE, 0, sizeof(struct scsi_caching_page), NULL, 310192468Ssam CTL_PAGE_FLAG_DISK_ONLY, NULL, ctl_caching_sp_handler}, 311192468Ssam {SMS_CONTROL_MODE_PAGE, 0, sizeof(struct scsi_control_page), NULL, 312192468Ssam CTL_PAGE_FLAG_NONE, NULL, ctl_control_page_handler}, 313192468Ssam {SMS_INFO_EXCEPTIONS_PAGE, 0, sizeof(struct scsi_info_exceptions_page), NULL, 314192468Ssam CTL_PAGE_FLAG_NONE, NULL, NULL}, 315192468Ssam {SMS_INFO_EXCEPTIONS_PAGE | SMPH_SPF, 0x02, 316192468Ssam sizeof(struct ctl_logical_block_provisioning_page), NULL, 317192468Ssam CTL_PAGE_FLAG_DISK_ONLY, NULL, NULL}, 318192468Ssam {SMS_VENDOR_SPECIFIC_PAGE | SMPH_SPF, DBGCNF_SUBPAGE_CODE, 319192468Ssam sizeof(struct copan_debugconf_subpage), NULL, CTL_PAGE_FLAG_NONE, 320192468Ssam ctl_debugconf_sp_sense_handler, ctl_debugconf_sp_select_handler}, 321192468Ssam}; 322192468Ssam 323192468Ssam#define CTL_NUM_MODE_PAGES sizeof(page_index_template)/ \ 324192468Ssam sizeof(page_index_template[0]) 325192468Ssam 326192468Ssamstruct ctl_mode_pages { 327192468Ssam struct scsi_da_rw_recovery_page rw_er_page[4]; 328192468Ssam struct scsi_format_page format_page[4]; 329192468Ssam struct scsi_rigid_disk_page rigid_disk_page[4]; 330192468Ssam struct scsi_caching_page caching_page[4]; 331192468Ssam struct scsi_control_page control_page[4]; 332192468Ssam struct scsi_info_exceptions_page ie_page[4]; 333192468Ssam struct ctl_logical_block_provisioning_page lbp_page[4]; 334192468Ssam struct copan_debugconf_subpage debugconf_subpage[4]; 335192468Ssam struct ctl_page_index index[CTL_NUM_MODE_PAGES]; 336192468Ssam}; 337192468Ssam 338192468Ssamstatic const struct ctl_page_index log_page_index_template[] = { 339192468Ssam {SLS_SUPPORTED_PAGES_PAGE, 0, 0, NULL, 340229952Sadrian CTL_PAGE_FLAG_NONE, NULL, NULL}, 341229952Sadrian {SLS_SUPPORTED_PAGES_PAGE, SLS_SUPPORTED_SUBPAGES_SUBPAGE, 0, NULL, 342229952Sadrian CTL_PAGE_FLAG_NONE, NULL, NULL}, 343229952Sadrian {SLS_LOGICAL_BLOCK_PROVISIONING, 0, 0, NULL, 344192468Ssam CTL_PAGE_FLAG_NONE, ctl_lbp_log_sense_handler, NULL}, 345192468Ssam}; 346192468Ssam 347192468Ssam#define CTL_NUM_LOG_PAGES sizeof(log_page_index_template)/ \ 348192468Ssam sizeof(log_page_index_template[0]) 349237214Sadrian 350237214Sadrianstruct ctl_log_pages { 351192468Ssam uint8_t pages_page[CTL_NUM_LOG_PAGES]; 352192468Ssam uint8_t subpages_page[CTL_NUM_LOG_PAGES * 2]; 353192468Ssam uint8_t lbp_page[12*CTL_NUM_LBP_PARAMS]; 354192468Ssam struct ctl_page_index index[CTL_NUM_LOG_PAGES]; 355192468Ssam}; 356192468Ssam 357192468Ssamstruct ctl_lun_delay_info { 358192468Ssam ctl_delay_type datamove_type; 359192468Ssam uint32_t datamove_delay; 360192468Ssam ctl_delay_type done_type; 361192468Ssam uint32_t done_delay; 362192468Ssam}; 363192468Ssam 364192468Ssamtypedef enum { 365192468Ssam CTL_ERR_INJ_NONE = 0x00, 366192468Ssam CTL_ERR_INJ_ABORTED = 0x01 367192468Ssam} ctl_err_inject_flags; 368192468Ssam 369192468Ssamtypedef enum { 370192468Ssam CTL_PR_FLAG_NONE = 0x00, 371192468Ssam CTL_PR_FLAG_REGISTERED = 0x01, 372192468Ssam CTL_PR_FLAG_ACTIVE_RES = 0x02 373192468Ssam} ctl_per_res_flags; 374 375#define CTL_PR_ALL_REGISTRANTS 0xFFFFFFFF 376#define CTL_PR_NO_RESERVATION 0xFFFFFFF0 377 378struct ctl_devid { 379 int len; 380 uint8_t data[]; 381}; 382 383/* 384 * For report target port groups. 385 */ 386#define NUM_TARGET_PORT_GROUPS 2 387 388#define CTL_WRITE_BUFFER_SIZE 262144 389 390struct tpc_list; 391struct ctl_lun { 392 struct mtx lun_lock; 393 struct ctl_id target; 394 uint64_t lun; 395 ctl_lun_flags flags; 396 ctl_lun_serseq serseq; 397 STAILQ_HEAD(,ctl_error_desc) error_list; 398 uint64_t error_serial; 399 struct ctl_softc *ctl_softc; 400 struct ctl_be_lun *be_lun; 401 struct ctl_backend_driver *backend; 402 int io_count; 403 struct ctl_lun_delay_info delay_info; 404 int sync_interval; 405 int sync_count; 406 TAILQ_HEAD(ctl_ooaq, ctl_io_hdr) ooa_queue; 407 TAILQ_HEAD(ctl_blockq,ctl_io_hdr) blocked_queue; 408 STAILQ_ENTRY(ctl_lun) links; 409 STAILQ_ENTRY(ctl_lun) run_links; 410#ifdef CTL_WITH_CA 411 uint32_t have_ca[CTL_MAX_INITIATORS >> 5]; 412 struct scsi_sense_data pending_sense[CTL_MAX_INITIATORS]; 413#endif 414 ctl_ua_type *pending_ua[CTL_MAX_PORTS]; 415 time_t lasttpt; 416 struct ctl_mode_pages mode_pages; 417 struct ctl_log_pages log_pages; 418 struct ctl_lun_io_stats stats; 419 uint32_t res_idx; 420 unsigned int PRGeneration; 421 uint64_t *pr_keys[2 * CTL_MAX_PORTS]; 422 int pr_key_count; 423 uint32_t pr_res_idx; 424 uint8_t res_type; 425 uint8_t *write_buffer; 426 struct ctl_devid *lun_devid; 427 TAILQ_HEAD(tpc_lists, tpc_list) tpc_lists; 428}; 429 430typedef enum { 431 CTL_FLAG_REAL_SYNC = 0x02, 432 CTL_FLAG_ACTIVE_SHELF = 0x04 433} ctl_gen_flags; 434 435#define CTL_MAX_THREADS 16 436 437struct ctl_thread { 438 struct mtx_padalign queue_lock; 439 struct ctl_softc *ctl_softc; 440 struct thread *thread; 441 STAILQ_HEAD(, ctl_io_hdr) incoming_queue; 442 STAILQ_HEAD(, ctl_io_hdr) rtr_queue; 443 STAILQ_HEAD(, ctl_io_hdr) done_queue; 444 STAILQ_HEAD(, ctl_io_hdr) isc_queue; 445}; 446 447struct tpc_token; 448struct ctl_softc { 449 struct mtx ctl_lock; 450 struct cdev *dev; 451 int open_count; 452 struct ctl_id target; 453 int num_disks; 454 int num_luns; 455 ctl_gen_flags flags; 456 ctl_ha_mode ha_mode; 457 int ha_id; 458 int ha_state; 459 int is_single; 460 int port_offset; 461 int persis_offset; 462 int inquiry_pq_no_lun; 463 struct sysctl_ctx_list sysctl_ctx; 464 struct sysctl_oid *sysctl_tree; 465 struct ctl_ioctl_info ioctl_info; 466 void *othersc_pool; 467 struct proc *ctl_proc; 468 int targ_online; 469 uint32_t ctl_lun_mask[(CTL_MAX_LUNS + 31) / 32]; 470 struct ctl_lun *ctl_luns[CTL_MAX_LUNS]; 471 uint32_t ctl_port_mask[(CTL_MAX_PORTS + 31) / 32]; 472 STAILQ_HEAD(, ctl_lun) lun_list; 473 STAILQ_HEAD(, ctl_be_lun) pending_lun_queue; 474 uint32_t num_frontends; 475 STAILQ_HEAD(, ctl_frontend) fe_list; 476 uint32_t num_ports; 477 STAILQ_HEAD(, ctl_port) port_list; 478 struct ctl_port *ctl_ports[CTL_MAX_PORTS]; 479 uint32_t num_backends; 480 STAILQ_HEAD(, ctl_backend_driver) be_list; 481 struct uma_zone *io_zone; 482 uint32_t cur_pool_id; 483 struct ctl_thread threads[CTL_MAX_THREADS]; 484 TAILQ_HEAD(tpc_tokens, tpc_token) tpc_tokens; 485 struct callout tpc_timeout; 486}; 487 488#ifdef _KERNEL 489 490extern const struct ctl_cmd_entry ctl_cmd_table[256]; 491 492uint32_t ctl_get_initindex(struct ctl_nexus *nexus); 493uint32_t ctl_get_resindex(struct ctl_nexus *nexus); 494uint32_t ctl_port_idx(int port_num); 495int ctl_pool_create(struct ctl_softc *ctl_softc, const char *pool_name, 496 uint32_t total_ctl_io, void **npool); 497void ctl_pool_free(struct ctl_io_pool *pool); 498int ctl_scsi_release(struct ctl_scsiio *ctsio); 499int ctl_scsi_reserve(struct ctl_scsiio *ctsio); 500int ctl_start_stop(struct ctl_scsiio *ctsio); 501int ctl_sync_cache(struct ctl_scsiio *ctsio); 502int ctl_format(struct ctl_scsiio *ctsio); 503int ctl_read_buffer(struct ctl_scsiio *ctsio); 504int ctl_write_buffer(struct ctl_scsiio *ctsio); 505int ctl_write_same(struct ctl_scsiio *ctsio); 506int ctl_unmap(struct ctl_scsiio *ctsio); 507int ctl_mode_select(struct ctl_scsiio *ctsio); 508int ctl_mode_sense(struct ctl_scsiio *ctsio); 509int ctl_log_sense(struct ctl_scsiio *ctsio); 510int ctl_read_capacity(struct ctl_scsiio *ctsio); 511int ctl_read_capacity_16(struct ctl_scsiio *ctsio); 512int ctl_read_defect(struct ctl_scsiio *ctsio); 513int ctl_read_write(struct ctl_scsiio *ctsio); 514int ctl_cnw(struct ctl_scsiio *ctsio); 515int ctl_report_luns(struct ctl_scsiio *ctsio); 516int ctl_request_sense(struct ctl_scsiio *ctsio); 517int ctl_tur(struct ctl_scsiio *ctsio); 518int ctl_verify(struct ctl_scsiio *ctsio); 519int ctl_inquiry(struct ctl_scsiio *ctsio); 520int ctl_persistent_reserve_in(struct ctl_scsiio *ctsio); 521int ctl_persistent_reserve_out(struct ctl_scsiio *ctsio); 522int ctl_report_tagret_port_groups(struct ctl_scsiio *ctsio); 523int ctl_report_supported_opcodes(struct ctl_scsiio *ctsio); 524int ctl_report_supported_tmf(struct ctl_scsiio *ctsio); 525int ctl_report_timestamp(struct ctl_scsiio *ctsio); 526int ctl_isc(struct ctl_scsiio *ctsio); 527int ctl_get_lba_status(struct ctl_scsiio *ctsio); 528 529void ctl_tpc_init(struct ctl_softc *softc); 530void ctl_tpc_shutdown(struct ctl_softc *softc); 531void ctl_tpc_lun_init(struct ctl_lun *lun); 532void ctl_tpc_lun_shutdown(struct ctl_lun *lun); 533int ctl_inquiry_evpd_tpc(struct ctl_scsiio *ctsio, int alloc_len); 534int ctl_receive_copy_status_lid1(struct ctl_scsiio *ctsio); 535int ctl_receive_copy_failure_details(struct ctl_scsiio *ctsio); 536int ctl_receive_copy_status_lid4(struct ctl_scsiio *ctsio); 537int ctl_receive_copy_operating_parameters(struct ctl_scsiio *ctsio); 538int ctl_extended_copy_lid1(struct ctl_scsiio *ctsio); 539int ctl_extended_copy_lid4(struct ctl_scsiio *ctsio); 540int ctl_copy_operation_abort(struct ctl_scsiio *ctsio); 541int ctl_populate_token(struct ctl_scsiio *ctsio); 542int ctl_write_using_token(struct ctl_scsiio *ctsio); 543int ctl_receive_rod_token_information(struct ctl_scsiio *ctsio); 544int ctl_report_all_rod_tokens(struct ctl_scsiio *ctsio); 545 546#endif /* _KERNEL */ 547 548#endif /* _CTL_PRIVATE_H_ */ 549 550/* 551 * vim: ts=8 552 */ 553