ctl_private.h revision 269296
1239268Sgonzo/*- 2244469Scognet * Copyright (c) 2003, 2004, 2005, 2008 Silicon Graphics International Corp. 3239268Sgonzo * All rights reserved. 4239268Sgonzo * 5239268Sgonzo * Redistribution and use in source and binary forms, with or without 6239268Sgonzo * modification, are permitted provided that the following conditions 7239268Sgonzo * are met: 8239268Sgonzo * 1. Redistributions of source code must retain the above copyright 9239268Sgonzo * notice, this list of conditions, and the following disclaimer, 10239268Sgonzo * without modification. 11239268Sgonzo * 2. Redistributions in binary form must reproduce at minimum a disclaimer 12239268Sgonzo * substantially similar to the "NO WARRANTY" disclaimer below 13239268Sgonzo * ("Disclaimer") and any redistribution must be conditioned upon 14239268Sgonzo * including a substantially similar Disclaimer requirement for further 15239268Sgonzo * binary redistribution. 16239268Sgonzo * 17239268Sgonzo * NO WARRANTY 18239268Sgonzo * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19239268Sgonzo * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20239268Sgonzo * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 21239268Sgonzo * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22239268Sgonzo * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23239268Sgonzo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24239268Sgonzo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25239268Sgonzo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26239268Sgonzo * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 27239268Sgonzo * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28239268Sgonzo * POSSIBILITY OF SUCH DAMAGES. 29239268Sgonzo * 30239268Sgonzo * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_private.h#7 $ 31239268Sgonzo * $FreeBSD: stable/10/sys/cam/ctl/ctl_private.h 269296 2014-07-30 07:18:32Z mav $ 32239268Sgonzo */ 33239268Sgonzo/* 34239268Sgonzo * CAM Target Layer driver private data structures/definitions. 35239268Sgonzo * 36239268Sgonzo * Author: Ken Merry <ken@FreeBSD.org> 37239268Sgonzo */ 38239268Sgonzo 39239268Sgonzo#ifndef _CTL_PRIVATE_H_ 40239268Sgonzo#define _CTL_PRIVATE_H_ 41239268Sgonzo 42239268Sgonzo/* 43239268Sgonzo * SCSI vendor and product names. 44244469Scognet */ 45239268Sgonzo#define CTL_VENDOR "FREEBSD " 46239268Sgonzo#define CTL_DIRECT_PRODUCT "CTLDISK " 47239268Sgonzo#define CTL_PROCESSOR_PRODUCT "CTLPROCESSOR " 48239268Sgonzo#define CTL_UNKNOWN_PRODUCT "CTLDEVICE " 49246713Skib 50239268Sgonzostruct ctl_fe_ioctl_startstop_info { 51239268Sgonzo struct cv sem; 52246713Skib struct ctl_hard_startstop_info hs_info; 53239268Sgonzo}; 54239268Sgonzo 55239268Sgonzostruct ctl_fe_ioctl_bbrread_info { 56239268Sgonzo struct cv sem; 57239268Sgonzo struct ctl_bbrread_info *bbr_info; 58244469Scognet int wakeup_done; 59244469Scognet struct mtx *lock; 60239268Sgonzo}; 61239268Sgonzo 62239268Sgonzotypedef enum { 63239268Sgonzo CTL_IOCTL_INPROG, 64239268Sgonzo CTL_IOCTL_DATAMOVE, 65239268Sgonzo CTL_IOCTL_DONE 66239268Sgonzo} ctl_fe_ioctl_state; 67239268Sgonzo 68239268Sgonzostruct ctl_fe_ioctl_params { 69239268Sgonzo struct cv sem; 70239268Sgonzo struct mtx ioctl_mtx; 71239268Sgonzo ctl_fe_ioctl_state state; 72239268Sgonzo}; 73239268Sgonzo 74239268Sgonzo#define CTL_POOL_ENTRIES_INTERNAL 200 75239268Sgonzo#define CTL_POOL_ENTRIES_EMERGENCY 300 76239268Sgonzo#define CTL_POOL_ENTRIES_OTHER_SC 200 77239268Sgonzo 78239268Sgonzotypedef enum { 79239268Sgonzo CTL_POOL_INTERNAL, 80239268Sgonzo CTL_POOL_FETD, 81239268Sgonzo CTL_POOL_EMERGENCY, 82239268Sgonzo CTL_POOL_4OTHERSC 83239268Sgonzo} ctl_pool_type; 84239268Sgonzo 85239268Sgonzotypedef enum { 86239268Sgonzo CTL_POOL_FLAG_NONE = 0x00, 87239268Sgonzo CTL_POOL_FLAG_INVALID = 0x01 88239268Sgonzo} ctl_pool_flags; 89239268Sgonzo 90239268Sgonzostruct ctl_io_pool { 91239268Sgonzo ctl_pool_type type; 92239268Sgonzo ctl_pool_flags flags; 93239268Sgonzo uint32_t id; 94239268Sgonzo struct ctl_softc *ctl_softc; 95239268Sgonzo uint32_t refcount; 96239268Sgonzo uint64_t total_allocated; 97239268Sgonzo uint64_t total_freed; 98239268Sgonzo int32_t total_ctl_io; 99244469Scognet int32_t free_ctl_io; 100244469Scognet STAILQ_HEAD(, ctl_io_hdr) free_queue; 101244469Scognet STAILQ_ENTRY(ctl_io_pool) links; 102244469Scognet}; 103244469Scognet 104244469Scognettypedef enum { 105244469Scognet CTL_IOCTL_FLAG_NONE = 0x00, 106239268Sgonzo CTL_IOCTL_FLAG_ENABLED = 0x01 107244469Scognet} ctl_ioctl_flags; 108239268Sgonzo 109239268Sgonzostruct ctl_ioctl_info { 110239268Sgonzo ctl_ioctl_flags flags; 111239268Sgonzo uint32_t cur_tag_num; 112239268Sgonzo struct ctl_port port; 113239268Sgonzo char port_name[24]; 114246713Skib}; 115239268Sgonzo 116239268Sgonzotypedef enum { 117239268Sgonzo CTL_SER_BLOCK, 118239268Sgonzo CTL_SER_EXTENT, 119239268Sgonzo CTL_SER_PASS, 120239268Sgonzo CTL_SER_SKIP 121239268Sgonzo} ctl_serialize_action; 122239268Sgonzo 123239268Sgonzotypedef enum { 124239268Sgonzo CTL_ACTION_BLOCK, 125239268Sgonzo CTL_ACTION_OVERLAP, 126239268Sgonzo CTL_ACTION_OVERLAP_TAG, 127239268Sgonzo CTL_ACTION_PASS, 128239268Sgonzo CTL_ACTION_SKIP, 129239268Sgonzo CTL_ACTION_ERROR 130239268Sgonzo} ctl_action; 131239268Sgonzo 132239268Sgonzo/* 133239268Sgonzo * WARNING: Keep the bottom nibble here free, we OR in the data direction 134239268Sgonzo * flags for each command. 135239268Sgonzo * 136239268Sgonzo * Note: "OK_ON_ALL_LUNS" == we don't have to have a lun configured 137239268Sgonzo * "OK_ON_BOTH" == we have to have a lun configured 138239268Sgonzo * "SA5" == command has 5-bit service action at byte 1 139239268Sgonzo */ 140239268Sgonzotypedef enum { 141239268Sgonzo CTL_CMD_FLAG_NONE = 0x0000, 142239268Sgonzo CTL_CMD_FLAG_NO_SENSE = 0x0010, 143239268Sgonzo CTL_CMD_FLAG_OK_ON_ALL_LUNS = 0x0020, 144239268Sgonzo CTL_CMD_FLAG_ALLOW_ON_RESV = 0x0040, 145239268Sgonzo CTL_CMD_FLAG_OK_ON_PROC = 0x0100, 146239268Sgonzo CTL_CMD_FLAG_OK_ON_SLUN = 0x0200, 147239268Sgonzo CTL_CMD_FLAG_OK_ON_BOTH = 0x0300, 148239268Sgonzo CTL_CMD_FLAG_OK_ON_STOPPED = 0x0400, 149239268Sgonzo CTL_CMD_FLAG_OK_ON_INOPERABLE = 0x0800, 150239268Sgonzo CTL_CMD_FLAG_OK_ON_OFFLINE = 0x1000, 151239268Sgonzo CTL_CMD_FLAG_OK_ON_SECONDARY = 0x2000, 152239268Sgonzo CTL_CMD_FLAG_ALLOW_ON_PR_RESV = 0x4000, 153239268Sgonzo CTL_CMD_FLAG_SA5 = 0x8000 154239268Sgonzo} ctl_cmd_flags; 155239268Sgonzo 156239268Sgonzotypedef enum { 157239268Sgonzo CTL_SERIDX_TUR = 0, 158239268Sgonzo CTL_SERIDX_READ, 159246713Skib CTL_SERIDX_WRITE, 160239268Sgonzo CTL_SERIDX_UNMAP, 161239268Sgonzo CTL_SERIDX_MD_SNS, 162239268Sgonzo CTL_SERIDX_MD_SEL, 163244469Scognet CTL_SERIDX_RQ_SNS, 164244469Scognet CTL_SERIDX_INQ, 165239268Sgonzo CTL_SERIDX_RD_CAP, 166246713Skib CTL_SERIDX_RES, 167246713Skib CTL_SERIDX_LOG_SNS, 168239268Sgonzo CTL_SERIDX_FORMAT, 169239268Sgonzo CTL_SERIDX_START, 170239268Sgonzo /* TBD: others to be filled in as needed */ 171239268Sgonzo CTL_SERIDX_COUNT, /* LAST, not a normal code, provides # codes */ 172239268Sgonzo CTL_SERIDX_INVLD = CTL_SERIDX_COUNT 173239268Sgonzo} ctl_seridx; 174239268Sgonzo 175239268Sgonzotypedef int ctl_opfunc(struct ctl_scsiio *ctsio); 176239268Sgonzo 177239268Sgonzostruct ctl_cmd_entry { 178239268Sgonzo ctl_opfunc *execute; 179246713Skib ctl_seridx seridx; 180246713Skib ctl_cmd_flags flags; 181239268Sgonzo ctl_lun_error_pattern pattern; 182239268Sgonzo uint8_t length; /* CDB length */ 183246713Skib uint8_t usage[15]; /* Mask of allowed CDB bits 184239268Sgonzo * after the opcode byte. */ 185246713Skib}; 186246713Skib 187246713Skibtypedef enum { 188246713Skib CTL_LUN_NONE = 0x000, 189239268Sgonzo CTL_LUN_CONTROL = 0x001, 190244469Scognet CTL_LUN_RESERVED = 0x002, 191244469Scognet CTL_LUN_INVALID = 0x004, 192244469Scognet CTL_LUN_DISABLED = 0x008, 193244469Scognet CTL_LUN_MALLOCED = 0x010, 194244469Scognet CTL_LUN_STOPPED = 0x020, 195244469Scognet CTL_LUN_INOPERABLE = 0x040, 196244469Scognet CTL_LUN_OFFLINE = 0x080, 197244469Scognet CTL_LUN_PR_RESERVED = 0x100, 198244469Scognet CTL_LUN_PRIMARY_SC = 0x200, 199244469Scognet CTL_LUN_SENSE_DESC = 0x400 200244469Scognet} ctl_lun_flags; 201244469Scognet 202244469Scognettypedef enum { 203244469Scognet CTLBLOCK_FLAG_NONE = 0x00, 204244469Scognet CTLBLOCK_FLAG_INVALID = 0x01 205244469Scognet} ctlblock_flags; 206244469Scognet 207244469Scognetunion ctl_softcs { 208244469Scognet struct ctl_softc *ctl_softc; 209244469Scognet struct ctlblock_softc *ctlblock_softc; 210244469Scognet}; 211244469Scognet 212244469Scognet/* 213244469Scognet * Mode page defaults. 214244469Scognet */ 215244469Scognet#if 0 216244469Scognet/* 217244469Scognet * These values make Solaris trim off some of the capacity. 218244469Scognet */ 219244469Scognet#define CTL_DEFAULT_SECTORS_PER_TRACK 63 220244469Scognet#define CTL_DEFAULT_HEADS 255 221244469Scognet/* 222239268Sgonzo * These values seem to work okay. 223239268Sgonzo */ 224239268Sgonzo#define CTL_DEFAULT_SECTORS_PER_TRACK 63 225239268Sgonzo#define CTL_DEFAULT_HEADS 16 226239268Sgonzo/* 227239268Sgonzo * These values work reasonably well. 228239268Sgonzo */ 229239268Sgonzo#define CTL_DEFAULT_SECTORS_PER_TRACK 512 230239268Sgonzo#define CTL_DEFAULT_HEADS 64 231239268Sgonzo#endif 232239268Sgonzo 233239268Sgonzo/* 234239268Sgonzo * Solaris is somewhat picky about how many heads and sectors per track you 235239268Sgonzo * have defined in mode pages 3 and 4. These values seem to cause Solaris 236239268Sgonzo * to get the capacity more or less right when you run the format tool. 237239268Sgonzo * They still have problems when dealing with devices larger than 1TB, 238239268Sgonzo * but there isn't anything we can do about that. 239239268Sgonzo * 240239268Sgonzo * For smaller LUN sizes, this ends up causing the number of cylinders to 241239268Sgonzo * work out to 0. Solaris actually recognizes that and comes up with its 242239268Sgonzo * own bogus geometry to fit the actual capacity of the drive. They really 243239268Sgonzo * should just give up on geometry and stick to the read capacity 244239268Sgonzo * information alone for modern disk drives. 245239268Sgonzo * 246239268Sgonzo * One thing worth mentioning about Solaris' mkfs command is that it 247239268Sgonzo * doesn't like sectors per track values larger than 256. 512 seems to 248239268Sgonzo * work okay for format, but causes problems when you try to make a 249239268Sgonzo * filesystem. 250239268Sgonzo * 251239268Sgonzo * Another caveat about these values: the product of these two values 252239268Sgonzo * really should be a power of 2. This is because of the simplistic 253239268Sgonzo * shift-based calculation that we have to use on the i386 platform to 254239268Sgonzo * calculate the number of cylinders here. (If you use a divide, you end 255239268Sgonzo * up calling __udivdi3(), which is a hardware FP call on the PC. On the 256239268Sgonzo * XScale, it is done in software, so you can do that from inside the 257239268Sgonzo * kernel.) 258239268Sgonzo * 259239268Sgonzo * So for the current values (256 S/T, 128 H), we get 32768, which works 260239268Sgonzo * very nicely for calculating cylinders. 261239268Sgonzo * 262239268Sgonzo * If you want to change these values so that their product is no longer a 263239268Sgonzo * power of 2, re-visit the calculation in ctl_init_page_index(). You may 264239268Sgonzo * need to make it a bit more complicated to get the number of cylinders 265239268Sgonzo * right. 266239268Sgonzo */ 267239268Sgonzo#define CTL_DEFAULT_SECTORS_PER_TRACK 256 268239268Sgonzo#define CTL_DEFAULT_HEADS 128 269239268Sgonzo 270239268Sgonzo#define CTL_DEFAULT_ROTATION_RATE 10000 271239268Sgonzo 272239268Sgonzostruct ctl_page_index; 273239268Sgonzo 274239268Sgonzotypedef int ctl_modesen_handler(struct ctl_scsiio *ctsio, 275239268Sgonzo struct ctl_page_index *page_index, 276239268Sgonzo int pc); 277239268Sgonzotypedef int ctl_modesel_handler(struct ctl_scsiio *ctsio, 278239268Sgonzo struct ctl_page_index *page_index, 279239268Sgonzo uint8_t *page_ptr); 280239268Sgonzo 281239268Sgonzotypedef enum { 282239268Sgonzo CTL_PAGE_FLAG_NONE = 0x00, 283239268Sgonzo CTL_PAGE_FLAG_DISK_ONLY = 0x01 284239268Sgonzo} ctl_page_flags; 285239268Sgonzo 286239268Sgonzostruct ctl_page_index { 287239268Sgonzo uint8_t page_code; 288239268Sgonzo uint8_t subpage; 289239268Sgonzo uint16_t page_len; 290239268Sgonzo uint8_t *page_data; 291239268Sgonzo ctl_page_flags page_flags; 292239268Sgonzo ctl_modesen_handler *sense_handler; 293239268Sgonzo ctl_modesel_handler *select_handler; 294239268Sgonzo}; 295239268Sgonzo 296239268Sgonzo#define CTL_PAGE_CURRENT 0x00 297239268Sgonzo#define CTL_PAGE_CHANGEABLE 0x01 298239268Sgonzo#define CTL_PAGE_DEFAULT 0x02 299239268Sgonzo#define CTL_PAGE_SAVED 0x03 300239268Sgonzo 301239268Sgonzostatic const struct ctl_page_index page_index_template[] = { 302239268Sgonzo {SMS_FORMAT_DEVICE_PAGE, 0, sizeof(struct scsi_format_page), NULL, 303239268Sgonzo CTL_PAGE_FLAG_DISK_ONLY, NULL, NULL}, 304239268Sgonzo {SMS_RIGID_DISK_PAGE, 0, sizeof(struct scsi_rigid_disk_page), NULL, 305239268Sgonzo CTL_PAGE_FLAG_DISK_ONLY, NULL, NULL}, 306239268Sgonzo {SMS_CACHING_PAGE, 0, sizeof(struct scsi_caching_page), NULL, 307239268Sgonzo CTL_PAGE_FLAG_DISK_ONLY, NULL, NULL}, 308239268Sgonzo {SMS_CONTROL_MODE_PAGE, 0, sizeof(struct scsi_control_page), NULL, 309239268Sgonzo CTL_PAGE_FLAG_NONE, NULL, ctl_control_page_handler}, 310239268Sgonzo {SMS_VENDOR_SPECIFIC_PAGE | SMPH_SPF, PWR_SUBPAGE_CODE, 311239268Sgonzo sizeof(struct copan_power_subpage), NULL, CTL_PAGE_FLAG_NONE, 312239268Sgonzo ctl_power_sp_sense_handler, ctl_power_sp_handler}, 313239268Sgonzo {SMS_VENDOR_SPECIFIC_PAGE | SMPH_SPF, APS_SUBPAGE_CODE, 314239268Sgonzo sizeof(struct copan_aps_subpage), NULL, CTL_PAGE_FLAG_NONE, 315239268Sgonzo NULL, ctl_aps_sp_handler}, 316239268Sgonzo {SMS_VENDOR_SPECIFIC_PAGE | SMPH_SPF, DBGCNF_SUBPAGE_CODE, 317239268Sgonzo sizeof(struct copan_debugconf_subpage), NULL, CTL_PAGE_FLAG_NONE, 318239268Sgonzo ctl_debugconf_sp_sense_handler, ctl_debugconf_sp_select_handler}, 319239268Sgonzo}; 320239268Sgonzo 321239268Sgonzo#define CTL_NUM_MODE_PAGES sizeof(page_index_template)/ \ 322239268Sgonzo sizeof(page_index_template[0]) 323239268Sgonzo 324239268Sgonzostruct ctl_mode_pages { 325239268Sgonzo struct scsi_format_page format_page[4]; 326239268Sgonzo struct scsi_rigid_disk_page rigid_disk_page[4]; 327239268Sgonzo struct scsi_caching_page caching_page[4]; 328239268Sgonzo struct scsi_control_page control_page[4]; 329239268Sgonzo struct copan_power_subpage power_subpage[4]; 330239268Sgonzo struct copan_aps_subpage aps_subpage[4]; 331239268Sgonzo struct copan_debugconf_subpage debugconf_subpage[4]; 332239268Sgonzo struct ctl_page_index index[CTL_NUM_MODE_PAGES]; 333239268Sgonzo}; 334239268Sgonzo 335239268Sgonzostruct ctl_pending_sense { 336239268Sgonzo ctl_ua_type ua_pending; 337239268Sgonzo struct scsi_sense_data sense; 338239268Sgonzo}; 339239268Sgonzo 340239268Sgonzostruct ctl_lun_delay_info { 341239268Sgonzo ctl_delay_type datamove_type; 342239268Sgonzo uint32_t datamove_delay; 343239268Sgonzo ctl_delay_type done_type; 344239268Sgonzo uint32_t done_delay; 345239268Sgonzo}; 346239268Sgonzo 347239268Sgonzotypedef enum { 348239268Sgonzo CTL_ERR_INJ_NONE = 0x00, 349239268Sgonzo CTL_ERR_INJ_ABORTED = 0x01 350239268Sgonzo} ctl_err_inject_flags; 351239268Sgonzo 352239268Sgonzotypedef enum { 353239268Sgonzo CTL_PR_FLAG_NONE = 0x00, 354239268Sgonzo CTL_PR_FLAG_REGISTERED = 0x01, 355239268Sgonzo CTL_PR_FLAG_ACTIVE_RES = 0x02 356239268Sgonzo} ctl_per_res_flags; 357239268Sgonzo 358239268Sgonzostruct ctl_per_res_info { 359239268Sgonzo struct scsi_per_res_key res_key; 360239268Sgonzo uint8_t registered; 361239268Sgonzo}; 362239268Sgonzo 363239268Sgonzo#define CTL_PR_ALL_REGISTRANTS 0xFFFF 364239268Sgonzo#define CTL_PR_NO_RESERVATION 0xFFF0 365239268Sgonzo 366239268Sgonzostruct ctl_devid { 367239268Sgonzo int len; 368239268Sgonzo uint8_t data[]; 369239268Sgonzo}; 370239268Sgonzo 371239268Sgonzo/* 372239268Sgonzo * For report target port groups. 373239268Sgonzo */ 374239268Sgonzo#define NUM_TARGET_PORT_GROUPS 2 375244469Scognet 376244469Scognetstruct tpc_list; 377244469Scognetstruct ctl_lun { 378244469Scognet struct mtx lun_lock; 379244469Scognet struct ctl_id target; 380244469Scognet uint64_t lun; 381244469Scognet ctl_lun_flags flags; 382244469Scognet STAILQ_HEAD(,ctl_error_desc) error_list; 383244469Scognet uint64_t error_serial; 384244469Scognet struct ctl_softc *ctl_softc; 385244469Scognet struct ctl_be_lun *be_lun; 386244469Scognet struct ctl_backend_driver *backend; 387239268Sgonzo int io_count; 388239268Sgonzo struct ctl_lun_delay_info delay_info; 389239268Sgonzo int sync_interval; 390239268Sgonzo int sync_count; 391239268Sgonzo TAILQ_HEAD(ctl_ooaq, ctl_io_hdr) ooa_queue; 392239268Sgonzo TAILQ_HEAD(ctl_blockq,ctl_io_hdr) blocked_queue; 393239268Sgonzo STAILQ_ENTRY(ctl_lun) links; 394239268Sgonzo STAILQ_ENTRY(ctl_lun) run_links; 395239268Sgonzo struct ctl_nexus rsv_nexus; 396239268Sgonzo uint32_t have_ca[CTL_MAX_INITIATORS >> 5]; 397239268Sgonzo struct ctl_pending_sense pending_sense[CTL_MAX_INITIATORS]; 398239268Sgonzo struct ctl_mode_pages mode_pages; 399239268Sgonzo struct ctl_lun_io_stats stats; 400239268Sgonzo struct ctl_per_res_info per_res[2*CTL_MAX_INITIATORS]; 401239268Sgonzo unsigned int PRGeneration; 402239268Sgonzo int pr_key_count; 403239268Sgonzo uint16_t pr_res_idx; 404239268Sgonzo uint8_t res_type; 405239268Sgonzo uint8_t write_buffer[524288]; 406239268Sgonzo struct ctl_devid *lun_devid; 407239268Sgonzo TAILQ_HEAD(tpc_lists, tpc_list) tpc_lists; 408239268Sgonzo}; 409239268Sgonzo 410239268Sgonzotypedef enum { 411239268Sgonzo CTL_FLAG_REAL_SYNC = 0x02, 412239268Sgonzo CTL_FLAG_MASTER_SHELF = 0x04 413239268Sgonzo} ctl_gen_flags; 414239268Sgonzo 415239268Sgonzo#define CTL_MAX_THREADS 16 416239268Sgonzo 417239268Sgonzostruct ctl_thread { 418239268Sgonzo struct mtx_padalign queue_lock; 419239268Sgonzo struct ctl_softc *ctl_softc; 420239268Sgonzo struct thread *thread; 421239268Sgonzo STAILQ_HEAD(, ctl_io_hdr) incoming_queue; 422239268Sgonzo STAILQ_HEAD(, ctl_io_hdr) rtr_queue; 423239268Sgonzo STAILQ_HEAD(, ctl_io_hdr) done_queue; 424239268Sgonzo STAILQ_HEAD(, ctl_io_hdr) isc_queue; 425239268Sgonzo}; 426239268Sgonzo 427239268Sgonzostruct ctl_softc { 428239268Sgonzo struct mtx ctl_lock; 429239268Sgonzo struct cdev *dev; 430239268Sgonzo int open_count; 431239268Sgonzo struct ctl_id target; 432239268Sgonzo int num_disks; 433239268Sgonzo int num_luns; 434239268Sgonzo ctl_gen_flags flags; 435239268Sgonzo ctl_ha_mode ha_mode; 436239268Sgonzo int inquiry_pq_no_lun; 437239268Sgonzo struct sysctl_ctx_list sysctl_ctx; 438239268Sgonzo struct sysctl_oid *sysctl_tree; 439239268Sgonzo struct ctl_ioctl_info ioctl_info; 440239268Sgonzo struct ctl_io_pool *internal_pool; 441239268Sgonzo struct ctl_io_pool *emergency_pool; 442239268Sgonzo struct ctl_io_pool *othersc_pool; 443239268Sgonzo struct proc *ctl_proc; 444239268Sgonzo int targ_online; 445239268Sgonzo uint32_t ctl_lun_mask[CTL_MAX_LUNS >> 5]; 446239268Sgonzo struct ctl_lun *ctl_luns[CTL_MAX_LUNS]; 447239268Sgonzo uint32_t ctl_port_mask; 448239268Sgonzo uint64_t aps_locked_lun; 449239268Sgonzo STAILQ_HEAD(, ctl_lun) lun_list; 450239268Sgonzo STAILQ_HEAD(, ctl_be_lun) pending_lun_queue; 451239268Sgonzo uint32_t num_frontends; 452239268Sgonzo STAILQ_HEAD(, ctl_frontend) fe_list; 453239268Sgonzo uint32_t num_ports; 454239268Sgonzo STAILQ_HEAD(, ctl_port) port_list; 455239268Sgonzo struct ctl_port *ctl_ports[CTL_MAX_PORTS]; 456239268Sgonzo uint32_t num_backends; 457239268Sgonzo STAILQ_HEAD(, ctl_backend_driver) be_list; 458239268Sgonzo struct mtx pool_lock; 459239268Sgonzo uint32_t num_pools; 460239268Sgonzo uint32_t cur_pool_id; 461239268Sgonzo STAILQ_HEAD(, ctl_io_pool) io_pools; 462239268Sgonzo time_t last_print_jiffies; 463239268Sgonzo uint32_t skipped_prints; 464239268Sgonzo struct ctl_thread threads[CTL_MAX_THREADS]; 465239268Sgonzo}; 466239268Sgonzo 467239268Sgonzo#ifdef _KERNEL 468239268Sgonzo 469239268Sgonzoextern const struct ctl_cmd_entry ctl_cmd_table[256]; 470239268Sgonzo 471239268Sgonzouint32_t ctl_get_initindex(struct ctl_nexus *nexus); 472239268Sgonzouint32_t ctl_get_resindex(struct ctl_nexus *nexus); 473239268Sgonzouint32_t ctl_port_idx(int port_num); 474239268Sgonzoint ctl_pool_create(struct ctl_softc *ctl_softc, ctl_pool_type pool_type, 475244469Scognet uint32_t total_ctl_io, struct ctl_io_pool **npool); 476244469Scognetvoid ctl_pool_free(struct ctl_io_pool *pool); 477239268Sgonzoint ctl_scsi_release(struct ctl_scsiio *ctsio); 478239268Sgonzoint ctl_scsi_reserve(struct ctl_scsiio *ctsio); 479239268Sgonzoint ctl_start_stop(struct ctl_scsiio *ctsio); 480239268Sgonzoint ctl_sync_cache(struct ctl_scsiio *ctsio); 481239268Sgonzoint ctl_format(struct ctl_scsiio *ctsio); 482239268Sgonzoint ctl_read_buffer(struct ctl_scsiio *ctsio); 483239268Sgonzoint ctl_write_buffer(struct ctl_scsiio *ctsio); 484239268Sgonzoint ctl_write_same(struct ctl_scsiio *ctsio); 485239268Sgonzoint ctl_unmap(struct ctl_scsiio *ctsio); 486239268Sgonzoint ctl_mode_select(struct ctl_scsiio *ctsio); 487239268Sgonzoint ctl_mode_sense(struct ctl_scsiio *ctsio); 488239268Sgonzoint ctl_read_capacity(struct ctl_scsiio *ctsio); 489239268Sgonzoint ctl_read_capacity_16(struct ctl_scsiio *ctsio); 490239268Sgonzoint ctl_read_write(struct ctl_scsiio *ctsio); 491239268Sgonzoint ctl_cnw(struct ctl_scsiio *ctsio); 492239268Sgonzoint ctl_report_luns(struct ctl_scsiio *ctsio); 493239268Sgonzoint ctl_request_sense(struct ctl_scsiio *ctsio); 494239268Sgonzoint ctl_tur(struct ctl_scsiio *ctsio); 495239268Sgonzoint ctl_verify(struct ctl_scsiio *ctsio); 496239268Sgonzoint ctl_inquiry(struct ctl_scsiio *ctsio); 497239268Sgonzoint ctl_persistent_reserve_in(struct ctl_scsiio *ctsio); 498239268Sgonzoint ctl_persistent_reserve_out(struct ctl_scsiio *ctsio); 499239268Sgonzoint ctl_report_tagret_port_groups(struct ctl_scsiio *ctsio); 500239268Sgonzoint ctl_report_supported_opcodes(struct ctl_scsiio *ctsio); 501246713Skibint ctl_report_supported_tmf(struct ctl_scsiio *ctsio); 502239268Sgonzoint ctl_report_timestamp(struct ctl_scsiio *ctsio); 503239268Sgonzoint ctl_isc(struct ctl_scsiio *ctsio); 504239268Sgonzo 505239268Sgonzovoid ctl_tpc_init(struct ctl_lun *lun); 506246713Skibvoid ctl_tpc_shutdown(struct ctl_lun *lun); 507246713Skibint ctl_inquiry_evpd_tpc(struct ctl_scsiio *ctsio, int alloc_len); 508239268Sgonzoint ctl_receive_copy_status_lid1(struct ctl_scsiio *ctsio); 509239268Sgonzoint ctl_receive_copy_failure_details(struct ctl_scsiio *ctsio); 510239268Sgonzoint ctl_receive_copy_status_lid4(struct ctl_scsiio *ctsio); 511239268Sgonzoint ctl_receive_copy_operating_parameters(struct ctl_scsiio *ctsio); 512246713Skibint ctl_extended_copy_lid1(struct ctl_scsiio *ctsio); 513239268Sgonzoint ctl_extended_copy_lid4(struct ctl_scsiio *ctsio); 514239268Sgonzoint ctl_copy_operation_abort(struct ctl_scsiio *ctsio); 515239268Sgonzo 516239268Sgonzo#endif /* _KERNEL */ 517239268Sgonzo 518239268Sgonzo#endif /* _CTL_PRIVATE_H_ */ 519239268Sgonzo 520239268Sgonzo/* 521239268Sgonzo * vim: ts=8 522239268Sgonzo */ 523239268Sgonzo