Print this page
usr/src/common/zfs/zprop_common.c
        
*** 16,31 ****
   * fields enclosed by brackets "[]" replaced with your own identifying
   * information: Portions Copyright [yyyy] [name of copyright owner]
   *
   * CDDL HEADER END
   */
  /*
   * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
   */
  /*
   * Copyright 2011 cyril.galibern@opensvc.com
!  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
   */
  
  #ifndef _SYS_SCSI_TARGETS_SDDEF_H
  #define _SYS_SCSI_TARGETS_SDDEF_H
  
--- 16,33 ----
   * fields enclosed by brackets "[]" replaced with your own identifying
   * information: Portions Copyright [yyyy] [name of copyright owner]
   *
   * CDDL HEADER END
   */
+ 
  /*
   * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
   */
+ 
  /*
   * Copyright 2011 cyril.galibern@opensvc.com
!  * Copyright 2019 Nexenta Systems, Inc.
   */
  
  #ifndef _SYS_SCSI_TARGETS_SDDEF_H
  #define _SYS_SCSI_TARGETS_SDDEF_H
  
*** 36,49 ****
  
  #ifdef  __cplusplus
  extern "C" {
  #endif
  
- 
  #if defined(_KERNEL) || defined(_KMEMUSER)
  
- 
  #define SD_SUCCESS              0
  #define SD_FAILURE              (-1)
  
  #if defined(TRUE)
  #undef TRUE
--- 38,49 ----
*** 54,92 ****
  #endif
  
  #define TRUE                    1
  #define FALSE                   0
  
- #if defined(VERBOSE)
- #undef VERBOSE
- #endif
- 
- #if defined(SILENT)
- #undef SILENT
- #endif
- 
- 
  /*
   *  Fault Injection Flag for Inclusion of Code
-  *
-  *  This should only be defined when SDDEBUG is defined
-  * #if DEBUG || lint
-  * #define      SD_FAULT_INJECTION
-  * #endif
   */
- 
  #if DEBUG || lint
  #define SD_FAULT_INJECTION
  #endif
- #define VERBOSE                 1
- #define SILENT                  0
  
  /*
   * Structures for recording whether a device is fully open or closed.
   * Assumptions:
   *
!  *      + There are only 8 (sparc) or 16 (x86) disk slices possible.
   *      + BLK, MNT, CHR, SWP don't change in some future release!
   */
  
  #if defined(_SUNOS_VTOC_8)
  
--- 54,75 ----
  #endif
  
  #define TRUE                    1
  #define FALSE                   0
  
  /*
   * Fault Injection Flag for Inclusion of Code
   */
  #if DEBUG || lint
  #define SD_FAULT_INJECTION
  #endif
  
  /*
   * Structures for recording whether a device is fully open or closed.
   * Assumptions:
   *
!  *      + There are only 16 disk slices possible.
   *      + BLK, MNT, CHR, SWP don't change in some future release!
   */
  
  #if defined(_SUNOS_VTOC_8)
  
*** 110,119 ****
--- 93,107 ----
  
  #else
  #error "No VTOC format defined."
  #endif
  
+ #define P0_RAW_DISK     (NDKMAP)
+ #define FDISK_P1        (NDKMAP+1)
+ #define FDISK_P2        (NDKMAP+2)
+ #define FDISK_P3        (NDKMAP+3)
+ #define FDISK_P4        (NDKMAP+4)
  
  #define SDUNIT(dev)     (getminor((dev)) >> SDUNIT_SHIFT)
  #define SDPART(dev)     (getminor((dev)) &  SDPART_MASK)
  
  /*
*** 129,140 ****
   * The instance number is encoded in the minor device number.
   */
  #define SD_GET_INSTANCE_FROM_BUF(bp)                            \
          (getminor((bp)->b_edev) >> SDUNIT_SHIFT)
  
- 
- 
  struct ocinfo {
          /*
           * Types BLK, MNT, CHR, SWP,
           * assumed to be types 0-3.
           */
--- 117,126 ----
*** 150,160 ****
  };
  
  #define lyropen rinfo.lyr_open
  #define regopen rinfo.reg_open
  
- 
  #define SD_CDB_GROUP0           0
  #define SD_CDB_GROUP1           1
  #define SD_CDB_GROUP5           2
  #define SD_CDB_GROUP4           3
  
--- 136,145 ----
*** 163,174 ****
          uchar_t  sc_grpmask;    /* CDB group code mask (for cmd opcode) */
          uint64_t sc_maxlba;     /* Maximum logical block addr. supported */
          uint32_t sc_maxlen;     /* Maximum transfer length supported */
  };
  
- 
- 
  /*
   * The following declaration are for Non-512 byte block support for the
   * removable devices. (ex - DVD RAM, MO).
   * wm_state: This is an enumeration for the different states for
   * manipalating write range list during the read-modify-write-operation.
--- 148,157 ----
*** 194,206 ****
          struct sd_w_map *wm_next;       /* Forward pointed to sd_w_map */
          struct sd_w_map *wm_prev;       /* Back pointer to sd_w_map */
          kcondvar_t      wm_avail;       /* Sleep on this, while not available */
  };
  
- _NOTE(MUTEX_PROTECTS_DATA(scsi_device::sd_mutex, sd_w_map::wm_flags))
- 
- 
  /*
   * This is the struct for the layer-private data area for the
   * mapblocksize layer.
   */
  
--- 177,186 ----
*** 210,223 ****
          struct sd_w_map *mbs_wmp;       /* ptr to write-map struct for RMW */
          ssize_t         mbs_copy_offset;
          int             mbs_layer_index;        /* chain index for RMW */
  };
  
! _NOTE(SCHEME_PROTECTS_DATA("unshared data", sd_mapblocksize_info))
  
  
  /*
   * sd_lun: The main data structure for a scsi logical unit.
   * Stored as the softstate structure for each device.
   */
  
  struct sd_lun {
--- 190,249 ----
          struct sd_w_map *mbs_wmp;       /* ptr to write-map struct for RMW */
          ssize_t         mbs_copy_offset;
          int             mbs_layer_index;        /* chain index for RMW */
  };
  
! /*
!  * Latency is tracked in usec and is quantized by power of two starting at
!  * offset SD_LAT_MIN_USEC_SHIFT. Values below that offset will go in the first
!  * (0th) bucket. Similar, values above SD_LAT_MAX_USEC_SHIFT go in the
!  * (SD_LAT_MAX_USEC_SHIFT - 1) bucket.
!  *
!  * From observations, using SAS SSDs and rotational drives these values are
!  * sufficient for now.
!  */
  
+ #define SD_LAT_MIN_USEC_SHIFT 4
+ #define SD_LAT_MAX_USEC_SHIFT 24
+ #define SD_LAT_BUCKET_MAX (SD_LAT_MAX_USEC_SHIFT - SD_LAT_MIN_USEC_SHIFT)
  
+ typedef struct un_lat_stat {
+         hrtime_t l_sum;                                 /* total latency  */
+         uint64_t l_nrequest;                            /* number of requests */
+         uint64_t l_histogram[SD_LAT_BUCKET_MAX];        /* latency histogram */
+ } un_lat_stat_t;
+ 
+ /* Thin-provisioning (UNMAP) flags for un_thin_flags. */
+ enum {
+         SD_THIN_PROV_ENABLED =          1 << 0, /* UNMAP available */
+         SD_THIN_PROV_READ_ZEROS =       1 << 1  /* unmapped blk = zeros */
+ };
+ 
  /*
+  * Device limits as read from the Block Limits VPD page (0xB0). If the page
+  * is unavailable, will be filled with some defaults.
+  */
+ typedef struct sd_blk_limits_s {
+         uint16_t        lim_opt_xfer_len_gran;
+         uint32_t        lim_max_xfer_len;
+         uint32_t        lim_opt_xfer_len;
+         uint32_t        lim_max_pfetch_len;
+         uint32_t        lim_max_unmap_lba_cnt;
+         uint32_t        lim_max_unmap_descr_cnt;
+         uint32_t        lim_opt_unmap_gran;
+         uint32_t        lim_unmap_gran_align;
+         uint64_t        lim_max_write_same_len;
+ } sd_blk_limits_t;
+ 
+ typedef struct sd_unmapstats {
+         kstat_named_t   us_cmds;
+         kstat_named_t   us_errs;
+         kstat_named_t   us_extents;
+         kstat_named_t   us_bytes;
+ } sd_unmapstats_t;
+ 
+ /*
   * sd_lun: The main data structure for a scsi logical unit.
   * Stored as the softstate structure for each device.
   */
  
  struct sd_lun {
*** 282,292 ****
          uint_t  un_busy_retry_count;    /* Per disk BUSY retry count */
  
          uint_t  un_retry_count;         /* Per disk retry count */
          uint_t  un_victim_retry_count;  /* Per disk victim retry count */
  
-         /* (4356701, 4367306) */
          uint_t  un_reset_retry_count; /* max io retries before issuing reset */
          ushort_t un_reserve_release_time; /* reservation release timeout */
  
          uchar_t un_reservation_type;    /* SCSI-3 or SCSI-2 */
          uint_t  un_max_xfer_size;       /* Maximum DMA transfer size */
--- 308,317 ----
*** 354,364 ****
--- 379,393 ----
           * stats, and other such bookkeeping info.
           */
          union   ocmap   un_ocmap;               /* open partition map */
          struct  kstat   *un_pstats[NSDMAP];     /* partition statistics */
          struct  kstat   *un_stats;              /* disk statistics */
+         sd_unmapstats_t *un_unmapstats;         /* UNMAP stats structure */
+         struct  kstat   *un_unmapstats_ks;      /* UNMAP kstat */
          kstat_t         *un_errstats;           /* for error statistics */
+         kstat_t         *un_lat_ksp;            /* pointer to the raw kstat */
+         un_lat_stat_t   *un_lat_stats;          /* data from the above kstat */
          uint64_t        un_exclopen;            /* exclusive open bitmask */
          ddi_devid_t     un_devid;               /* device id */
          uint_t          un_vpd_page_mask;       /* Supported VPD pages */
  
          /*
*** 400,410 ****
              un_f_mmc_cap                :1,     /* Device is MMC compliant */
              un_f_mmc_writable_media     :1,     /* writable media in device */
              un_f_dvdram_writable_device :1,     /* DVDRAM device is writable */
              un_f_cfg_cdda               :1,     /* READ CDDA supported */
              un_f_cfg_tur_check          :1,     /* verify un_ncmds before tur */
- 
              un_f_use_adaptive_throttle  :1,     /* enable/disable adaptive */
                                                  /* throttling */
              un_f_pm_is_enabled          :1,     /* PM is enabled on this */
                                                  /* instance */
              un_f_watcht_stopped         :1,     /* media watch thread flag */
--- 429,438 ----
*** 414,424 ****
              un_f_disksort_disabled      :1,     /* Flag to disable disksort */
              un_f_lun_reset_enabled      :1,     /* Set if target supports */
                                                  /* SCSI Logical Unit Reset */
              un_f_doorlock_supported     :1,     /* Device supports Doorlock */
              un_f_start_stop_supported   :1,     /* device has motor */
!             un_f_reserved1              :1;
  
          uint32_t
              un_f_mboot_supported        :1,     /* mboot supported */
              un_f_is_hotpluggable        :1,     /* hotpluggable */
              un_f_has_removable_media    :1,     /* has removable media */
--- 442,452 ----
              un_f_disksort_disabled      :1,     /* Flag to disable disksort */
              un_f_lun_reset_enabled      :1,     /* Set if target supports */
                                                  /* SCSI Logical Unit Reset */
              un_f_doorlock_supported     :1,     /* Device supports Doorlock */
              un_f_start_stop_supported   :1,     /* device has motor */
!             un_f_sdconf_phy_blocksize   :1;     /* take pbs from sd.conf */
  
          uint32_t
              un_f_mboot_supported        :1,     /* mboot supported */
              un_f_is_hotpluggable        :1,     /* hotpluggable */
              un_f_has_removable_media    :1,     /* has removable media */
*** 464,478 ****
              un_f_mmc_gesn_polling       :1,     /* use GET EVENT STATUS */
                                                  /* NOTIFICATION for polling */
              un_f_enable_rmw             :1,     /* Force RMW in sd driver */
              un_f_expnevent              :1,
              un_f_cache_mode_changeable  :1,     /* can change cache mode */
!             un_f_reserved               :1;
  
          /* Ptr to table of strings for ASC/ASCQ error message printing */
          struct scsi_asq_key_strings     *un_additional_codes;
  
          /*
           * Power Management support.
           *
           * un_pm_mutex protects, un_pm_count, un_pm_timeid, un_pm_busy,
           * un_pm_busy_cv, and un_pm_idle_timeid.
--- 492,507 ----
              un_f_mmc_gesn_polling       :1,     /* use GET EVENT STATUS */
                                                  /* NOTIFICATION for polling */
              un_f_enable_rmw             :1,     /* Force RMW in sd driver */
              un_f_expnevent              :1,
              un_f_cache_mode_changeable  :1,     /* can change cache mode */
!             un_f_detach_waiting         :1;
  
          /* Ptr to table of strings for ASC/ASCQ error message printing */
          struct scsi_asq_key_strings     *un_additional_codes;
  
+         kcondvar_t      un_detach_cv;
          /*
           * Power Management support.
           *
           * un_pm_mutex protects, un_pm_count, un_pm_timeid, un_pm_busy,
           * un_pm_busy_cv, and un_pm_idle_timeid.
*** 506,515 ****
--- 535,550 ----
          uint_t          un_rmw_count;   /* count of read-modify-writes */
          struct sd_w_map *un_wm;         /* head of sd_w_map chain */
          uint64_t        un_rmw_incre_count;     /* count I/O */
          timeout_id_t    un_rmw_msg_timeid;      /* for RMW message control */
  
+         /* Thin provisioning support (see SD_THIN_PROV_*) */
+         uint64_t        un_thin_flags;
+ 
+         /* Block limits (0xB0 VPD page) */
+         sd_blk_limits_t un_blk_lim;
+ 
          /* For timeout callback to issue a START STOP UNIT command */
          timeout_id_t    un_startstop_timeid;
  
          /* Timeout callback handle for SD_PATH_DIRECT_PRIORITY cmd restarts */
          timeout_id_t    un_direct_priority_timeid;
*** 527,536 ****
--- 562,574 ----
           * failing over, and how many I/O's are failed with the 05/94/01
           * sense code.
           */
          uint_t          un_sonoma_failure_count;
  
+         int             un_io_time;
+         hrtime_t        un_slow_io_threshold;
+ 
          /*
           * Support for failfast operation.
           */
          struct buf      *un_failfast_bp;
          struct buf      *un_failfast_headp;
*** 541,564 ****
  
          kcondvar_t      un_wcc_cv;      /* synchronize changes to */
                                          /* un_f_write_cache_enabled */
  
  #ifdef SD_FAULT_INJECTION
-         /* SD Fault Injection */
  #define SD_FI_MAX_BUF 65536
  #define SD_FI_MAX_ERROR 1024
          kmutex_t                        un_fi_mutex;
          uint_t                          sd_fi_buf_len;
          char                            sd_fi_log[SD_FI_MAX_BUF];
          struct sd_fi_pkt        *sd_fi_fifo_pkt[SD_FI_MAX_ERROR];
          struct sd_fi_xb         *sd_fi_fifo_xb[SD_FI_MAX_ERROR];
          struct sd_fi_un         *sd_fi_fifo_un[SD_FI_MAX_ERROR];
          struct sd_fi_arq        *sd_fi_fifo_arq[SD_FI_MAX_ERROR];
          uint_t                          sd_fi_fifo_start;
          uint_t                          sd_fi_fifo_end;
          uint_t                          sd_injection_mask;
- 
  #endif
  
          cmlb_handle_t   un_cmlbhandle;
  
          /*
--- 579,601 ----
  
          kcondvar_t      un_wcc_cv;      /* synchronize changes to */
                                          /* un_f_write_cache_enabled */
  
  #ifdef SD_FAULT_INJECTION
  #define SD_FI_MAX_BUF 65536
  #define SD_FI_MAX_ERROR 1024
          kmutex_t                        un_fi_mutex;
          uint_t                          sd_fi_buf_len;
          char                            sd_fi_log[SD_FI_MAX_BUF];
          struct sd_fi_pkt        *sd_fi_fifo_pkt[SD_FI_MAX_ERROR];
          struct sd_fi_xb         *sd_fi_fifo_xb[SD_FI_MAX_ERROR];
          struct sd_fi_un         *sd_fi_fifo_un[SD_FI_MAX_ERROR];
          struct sd_fi_arq        *sd_fi_fifo_arq[SD_FI_MAX_ERROR];
+         struct sd_fi_tran       *sd_fi_fifo_tran[SD_FI_MAX_ERROR];
          uint_t                          sd_fi_fifo_start;
          uint_t                          sd_fi_fifo_end;
          uint_t                          sd_injection_mask;
  #endif
  
          cmlb_handle_t   un_cmlbhandle;
  
          /*
*** 630,733 ****
  /*
   * SD_DEFAULT_MAX_XFER_SIZE is the default value to bound the max xfer
   * for physio, for devices without tagged queuing enabled.
   * The default for devices with tagged queuing enabled is SD_MAX_XFER_SIZE
   */
- #if defined(__i386) || defined(__amd64)
  #define SD_DEFAULT_MAX_XFER_SIZE        (256 * 1024)
- #endif
  #define SD_MAX_XFER_SIZE                (1024 * 1024)
  
  /*
-  * Warlock annotations
-  */
- _NOTE(MUTEX_PROTECTS_DATA(scsi_device::sd_mutex, sd_lun))
- _NOTE(READ_ONLY_DATA(sd_lun::un_sd))
- _NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_reservation_type))
- _NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_mincdb))
- _NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_maxcdb))
- _NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_max_hba_cdb))
- _NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_status_len))
- _NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_f_arq_enabled))
- _NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_ctype))
- _NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_cmlbhandle))
- _NOTE(DATA_READABLE_WITHOUT_LOCK(sd_lun::un_fm_private))
- 
- 
- _NOTE(SCHEME_PROTECTS_DATA("safe sharing",
-         sd_lun::un_mhd_token
-         sd_lun::un_state
-         sd_lun::un_tagflags
-         sd_lun::un_f_format_in_progress
-         sd_lun::un_resvd_timeid
-         sd_lun::un_reset_throttle_timeid
-         sd_lun::un_startstop_timeid
-         sd_lun::un_dcvb_timeid
-         sd_lun::un_f_allow_bus_device_reset
-         sd_lun::un_sys_blocksize
-         sd_lun::un_tgt_blocksize
-         sd_lun::un_phy_blocksize
-         sd_lun::un_additional_codes))
- 
- _NOTE(SCHEME_PROTECTS_DATA("stable data",
-         sd_lun::un_reserve_release_time
-         sd_lun::un_max_xfer_size
-         sd_lun::un_partial_dma_supported
-         sd_lun::un_buf_breakup_supported
-         sd_lun::un_f_is_fibre
-         sd_lun::un_node_type
-         sd_lun::un_buf_chain_type
-         sd_lun::un_uscsi_chain_type
-         sd_lun::un_direct_chain_type
-         sd_lun::un_priority_chain_type
-         sd_lun::un_xbuf_attr
-         sd_lun::un_cmd_timeout
-         sd_lun::un_pkt_flags))
- 
- _NOTE(SCHEME_PROTECTS_DATA("Unshared data",
-         block_descriptor
-         buf
-         cdrom_subchnl
-         cdrom_tocentry
-         cdrom_tochdr
-         cdrom_read
-         dk_cinfo
-         dk_devid
-         dk_label
-         dk_map
-         dk_temperature
-         mhioc_inkeys
-         mhioc_inresvs
-         mode_caching
-         mode_header
-         mode_speed
-         scsi_cdb
-         scsi_arq_status
-         scsi_extended_sense
-         scsi_inquiry
-         scsi_pkt
-         uio
-         uscsi_cmd))
- 
- 
- _NOTE(SCHEME_PROTECTS_DATA("stable data", scsi_device dk_cinfo))
- _NOTE(SCHEME_PROTECTS_DATA("unique per pkt", scsi_status scsi_cdb))
- 
- _NOTE(MUTEX_PROTECTS_DATA(sd_lun::un_pm_mutex, sd_lun::un_pm_count
-         sd_lun::un_pm_timeid sd_lun::un_pm_busy sd_lun::un_pm_busy_cv
-         sd_lun::un_pm_idle_timeid))
- 
- #ifdef SD_FAULT_INJECTION
- _NOTE(MUTEX_PROTECTS_DATA(sd_lun::un_fi_mutex,
-         sd_lun::sd_fi_buf_len sd_lun::sd_fi_log))
- #endif
- 
- /* _NOTE(LOCK_ORDER(sd_lun::un_sd.sd_mutex sd_lun::un_pm_mutex)) */
- 
- 
- 
- /*
   * Referenced for frequently-accessed members of the unit structure
   */
  #define SD_SCSI_DEVP(un)        ((un)->un_sd)
  #define SD_DEVINFO(un)          ((un)->un_sd->sd_dev)
  #define SD_INQUIRY(un)          ((un)->un_sd->sd_inq)
--- 667,680 ----
*** 735,745 ****
  #define SD_ADDRESS(un)          (&((un)->un_sd->sd_address))
  #define SD_GET_DEV(un)          (sd_make_device(SD_DEVINFO(un)))
  #define SD_FM_LOG(un)           (((struct sd_fm_internal *)\
                                  ((un)->un_fm_private))->fm_log_level)
  
- 
  /*
   * Values for un_ctype
   */
  #define CTYPE_CDROM             0
  #define CTYPE_MD21              1       /* Obsolete! */
--- 682,691 ----
*** 956,972 ****
          kcondvar_t              srq_inprocess_cv;
          kmutex_t                srq_resv_reclaim_mutex;
          kcondvar_t              srq_resv_reclaim_cv;
  };
  
- _NOTE(MUTEX_PROTECTS_DATA(sd_resv_reclaim_request::srq_resv_reclaim_mutex,
-     sd_resv_reclaim_request))
- _NOTE(SCHEME_PROTECTS_DATA("unshared data", sd_thr_request))
- _NOTE(SCHEME_PROTECTS_DATA("Unshared data", sd_prout))
- 
- 
- 
  /*
   * Driver Logging Components
   *
   * These components cover the functional entry points and areas of the
   * driver.  A component value is used for the entry point and utility
--- 902,911 ----
*** 1047,1056 ****
--- 986,997 ----
   * sd_fi_un replicates the variables that are exposed through un
   *
   * sd_fi_arq replicates the variables that are
   *           exposed for Auto-Reqeust-Sense
   *
+  * sd_fi_tran HBA-level fault injection.
+  *
   */
  struct sd_fi_pkt {
          uint_t  pkt_flags;                      /* flags */
          uchar_t pkt_scbp;                       /* pointer to status block */
          uchar_t pkt_cdbp;                       /* pointer to command block */
*** 1097,1106 ****
--- 1038,1056 ----
          uint_t                          sts_rqpkt_state;
          uint_t                          sts_rqpkt_statistics;
          struct scsi_extended_sense      sts_sensedata;
  };
  
+ enum sd_fi_tran_cmd {
+         SD_FLTINJ_CMD_BUSY, /* Reject command instead of sending it to HW */
+         SD_FLTINJ_CMD_TIMEOUT /* Time-out command. */
+ };
+ 
+ struct sd_fi_tran {
+         enum sd_fi_tran_cmd tran_cmd;
+ };
+ 
  /*
   * Conditional set def
   */
  #define SD_CONDSET(a, b, c, d)                  \
          { \
*** 1120,1129 ****
--- 1070,1080 ----
  #define SDIOCINSERTUN   (SDIOC|5)
  #define SDIOCINSERTARQ  (SDIOC|6)
  #define SDIOCPUSH       (SDIOC|7)
  #define SDIOCRETRIEVE   (SDIOC|8)
  #define SDIOCRUN        (SDIOC|9)
+ #define SDIOCINSERTTRAN (SDIOC|0xA)
  #endif
  
  #else
  
  #undef  SDDEBUG
*** 1172,1181 ****
--- 1123,1134 ----
  #define SD_STATE_OFFLINE        1
  #define SD_STATE_RWAIT          2
  #define SD_STATE_DUMPING        3
  #define SD_STATE_SUSPENDED      4
  #define SD_STATE_PM_CHANGING    5
+ #define SD_STATE_ATTACHING      6
+ #define SD_STATE_ATTACH_FAILED  7
  
  /*
   * The table is to be interpreted as follows: The rows lists all the states
   * and each column is a state that a state in each row *can* reach. The entries
   * in the table list the event that cause that transition to take place.
*** 1226,1237 ****
   * (0 is a special case) which means it would never get set back to
   * un_saved_throttle in routine sd_restore_throttle().
   */
  #define SD_LOWEST_VALID_THROTTLE        2
  
- 
- 
  /* Return codes for sd_send_polled_cmd() and sd_scsi_poll() */
  #define SD_CMD_SUCCESS                  0
  #define SD_CMD_FAILURE                  1
  #define SD_CMD_RESERVATION_CONFLICT     2
  #define SD_CMD_ILLEGAL_REQUEST          3
--- 1179,1188 ----
*** 1418,1429 ****
           * right after xb_sense_data[SENSE_LENGTH]. Please do not
           * add any new field after it.
           */
  };
  
- _NOTE(SCHEME_PROTECTS_DATA("unique per pkt", sd_xbuf))
- 
  #define SD_PKT_ALLOC_SUCCESS                    0
  #define SD_PKT_ALLOC_FAILURE                    1
  #define SD_PKT_ALLOC_FAILURE_NO_DMA             2
  #define SD_PKT_ALLOC_FAILURE_PKT_TOO_SMALL      3
  #define SD_PKT_ALLOC_FAILURE_CDB_TOO_SMALL      4
--- 1369,1378 ----
*** 1453,1464 ****
          uint32_t                ui_pkt_statistics;
          uint64_t                ui_lba;
          uint64_t                ui_ena;
  };
  
- _NOTE(SCHEME_PROTECTS_DATA("Unshared data", sd_uscsi_info))
- 
  /*
   * This structure is used to issue 'internal' command sequences from the
   * driver's attach(9E)/open(9E)/etc entry points. It provides a common context
   * for issuing command sequences, with the ability to issue a command
   * and provide expected/unexpected assessment of results at any code
--- 1402,1411 ----
*** 1495,1506 ****
          struct sd_uscsi_info    *ssc_uscsi_info;
          int                     ssc_flags; /* Bits for flags */
          char                    ssc_info[1024]; /* Buffer holding for info */
  } sd_ssc_t;
  
- _NOTE(SCHEME_PROTECTS_DATA("Unshared data", sd_ssc_t))
- 
  /*
   * This struct switch different 'type-of-assessment'
   * as an input argument for sd_ssc_assessment
   *
   *
--- 1442,1451 ----
*** 1703,1716 ****
  
  #endif  /* defined(_KERNEL) || defined(_KMEMUSER) */
  
  
  /*
!  * 60 seconds is a *very* reasonable amount of time for most slow CD
!  * operations.
   */
! #define SD_IO_TIME                      60
  
  /*
   * 2 hours is an excessively reasonable amount of time for format operations.
   */
  #define SD_FMT_TIME                     (120 * 60)
--- 1648,1661 ----
  
  #endif  /* defined(_KERNEL) || defined(_KMEMUSER) */
  
  
  /*
!  * 15 seconds is a *very* reasonable amount of time for any device with retries.
!  * Doubled for slow CD operations.
   */
! #define SD_IO_TIME                      15
  
  /*
   * 2 hours is an excessively reasonable amount of time for format operations.
   */
  #define SD_FMT_TIME                     (120 * 60)
*** 1737,1769 ****
  
  /*
   * 100 msec. is what we'll wait for certain retries for fibre channel
   * targets, 0 msec for parallel SCSI.
   */
- #if defined(__fibre)
- #define SD_RETRY_DELAY                  (drv_usectohz(100000))
- #else
  #define SD_RETRY_DELAY                  ((clock_t)0)
- #endif
  
  /*
   * Number of times we'll retry a normal operation.
   *
   * This includes retries due to transport failure
   * (need to distinguish between Target and Transport failure)
   *
   */
- #if defined(__fibre)
- #define SD_RETRY_COUNT                  3
- #else
  #define SD_RETRY_COUNT                  5
- #endif
  
  /*
   * Number of times we will retry for unit attention.
   */
! #define SD_UA_RETRY_COUNT               600
  
  #define SD_VICTIM_RETRY_COUNT(un)       (un->un_victim_retry_count)
  #define CD_NOT_READY_RETRY_COUNT(un)    (un->un_retry_count * 2)
  #define DISK_NOT_READY_RETRY_COUNT(un)  (un->un_retry_count / 2)
  
--- 1682,1706 ----
  
  /*
   * 100 msec. is what we'll wait for certain retries for fibre channel
   * targets, 0 msec for parallel SCSI.
   */
  #define SD_RETRY_DELAY                  ((clock_t)0)
  
  /*
   * Number of times we'll retry a normal operation.
   *
   * This includes retries due to transport failure
   * (need to distinguish between Target and Transport failure)
   *
   */
  #define SD_RETRY_COUNT                  5
  
  /*
   * Number of times we will retry for unit attention.
   */
! #define SD_UA_RETRY_COUNT               25
  
  #define SD_VICTIM_RETRY_COUNT(un)       (un->un_victim_retry_count)
  #define CD_NOT_READY_RETRY_COUNT(un)    (un->un_retry_count * 2)
  #define DISK_NOT_READY_RETRY_COUNT(un)  (un->un_retry_count / 2)
  
*** 1867,1879 ****
  #define PIRUS_DISKSORT_DISABLED_FLAG    0
  #define PIRUS_LUN_RESET_ENABLED_FLAG    1
  
  /*
   * Driver Property Bit Flag definitions
-  *
-  * Unfortunately, for historical reasons, the bit-flag definitions are
-  * different on SPARC, INTEL, & FIBRE platforms.
   */
  
  /*
   * Bit flag telling driver to set throttle from sd.conf sd-config-list
   * and driver table.
--- 1804,1813 ----
*** 1888,2017 ****
  
  /*
   * Bit flag telling driver to set the controller type from sd.conf
   * sd-config-list and driver table.
   */
- #if defined(__i386) || defined(__amd64)
  #define SD_CONF_SET_CTYPE               1
- #elif defined(__fibre)
- #define SD_CONF_SET_CTYPE               5
- #else
- #define SD_CONF_SET_CTYPE               1
- #endif
  #define SD_CONF_BSET_CTYPE              (1 << SD_CONF_SET_CTYPE)
  
  /*
   * Bit flag telling driver to set the not ready retry count for a device from
   * sd.conf sd-config-list and driver table.
   */
- #if defined(__i386) || defined(__amd64)
  #define SD_CONF_SET_NOTREADY_RETRIES    10
- #elif defined(__fibre)
- #define SD_CONF_SET_NOTREADY_RETRIES    1
- #else
- #define SD_CONF_SET_NOTREADY_RETRIES    2
- #endif
  #define SD_CONF_BSET_NRR_COUNT          (1 << SD_CONF_SET_NOTREADY_RETRIES)
  
  /*
   * Bit flag telling driver to set SCSI status BUSY Retries from sd.conf
   * sd-config-list and driver table.
   */
- #if defined(__i386) || defined(__amd64)
  #define SD_CONF_SET_BUSY_RETRIES        11
- #elif defined(__fibre)
- #define SD_CONF_SET_BUSY_RETRIES        2
- #else
- #define SD_CONF_SET_BUSY_RETRIES        5
- #endif
  #define SD_CONF_BSET_BSY_RETRY_COUNT    (1 << SD_CONF_SET_BUSY_RETRIES)
  
  /*
   * Bit flag telling driver that device does not have a valid/unique serial
   * number.
   */
- #if defined(__i386) || defined(__amd64)
  #define SD_CONF_SET_FAB_DEVID           2
- #else
- #define SD_CONF_SET_FAB_DEVID           3
- #endif
  #define SD_CONF_BSET_FAB_DEVID          (1 << SD_CONF_SET_FAB_DEVID)
  
  /*
   * Bit flag telling driver to disable all caching for disk device.
   */
- #if defined(__i386) || defined(__amd64)
  #define SD_CONF_SET_NOCACHE             3
- #else
- #define SD_CONF_SET_NOCACHE             4
- #endif
  #define SD_CONF_BSET_NOCACHE            (1 << SD_CONF_SET_NOCACHE)
  
  /*
   * Bit flag telling driver that the PLAY AUDIO command requires parms in BCD
   * format rather than binary.
   */
- #if defined(__i386) || defined(__amd64)
  #define SD_CONF_SET_PLAYMSF_BCD         4
- #else
- #define SD_CONF_SET_PLAYMSF_BCD         6
- #endif
  #define SD_CONF_BSET_PLAYMSF_BCD        (1 << SD_CONF_SET_PLAYMSF_BCD)
  
  /*
   * Bit flag telling driver that the response from the READ SUBCHANNEL command
   * has BCD fields rather than binary.
   */
- #if defined(__i386) || defined(__amd64)
  #define SD_CONF_SET_READSUB_BCD         5
- #else
- #define SD_CONF_SET_READSUB_BCD         7
- #endif
  #define SD_CONF_BSET_READSUB_BCD        (1 << SD_CONF_SET_READSUB_BCD)
  
  /*
   * Bit in flags telling driver that the track number fields in the READ TOC
   * request and respone are in BCD rather than binary.
   */
- #if defined(__i386) || defined(__amd64)
  #define SD_CONF_SET_READ_TOC_TRK_BCD    6
- #else
- #define SD_CONF_SET_READ_TOC_TRK_BCD    8
- #endif
  #define SD_CONF_BSET_READ_TOC_TRK_BCD   (1 << SD_CONF_SET_READ_TOC_TRK_BCD)
  
  /*
   * Bit flag telling driver that the address fields in the READ TOC request and
   * respone are in BCD rather than binary.
   */
- #if defined(__i386) || defined(__amd64)
  #define SD_CONF_SET_READ_TOC_ADDR_BCD   7
- #else
- #define SD_CONF_SET_READ_TOC_ADDR_BCD   9
- #endif
  #define SD_CONF_BSET_READ_TOC_ADDR_BCD  (1 << SD_CONF_SET_READ_TOC_ADDR_BCD)
  
  /*
   * Bit flag telling the driver that the device doesn't support the READ HEADER
   * command.
   */
- #if defined(__i386) || defined(__amd64)
  #define SD_CONF_SET_NO_READ_HEADER      8
- #else
- #define SD_CONF_SET_NO_READ_HEADER      10
- #endif
  #define SD_CONF_BSET_NO_READ_HEADER     (1 << SD_CONF_SET_NO_READ_HEADER)
  
  /*
   * Bit flag telling the driver that for the READ CD command the device uses
   * opcode 0xd4 rather than 0xbe.
   */
- #if defined(__i386) || defined(__amd64)
  #define SD_CONF_SET_READ_CD_XD4         9
- #else
- #define SD_CONF_SET_READ_CD_XD4         11
- #endif
  #define SD_CONF_BSET_READ_CD_XD4        (1 << SD_CONF_SET_READ_CD_XD4)
  
  /*
   * Bit flag telling the driver to set SCSI status Reset Retries
   * (un_reset_retry_count) from sd.conf sd-config-list and driver table (4356701)
--- 1822,1901 ----
*** 2033,2058 ****
   */
  #define SD_CONF_SET_TUR_CHECK           14
  #define SD_CONF_BSET_TUR_CHECK          (1 << SD_CONF_SET_TUR_CHECK)
  
  /*
!  * Bit in flags telling driver to set min. throttle from ssd.conf
!  * ssd-config-list and driver table.
   */
  #define SD_CONF_SET_MIN_THROTTLE        15
  #define SD_CONF_BSET_MIN_THROTTLE       (1 << SD_CONF_SET_MIN_THROTTLE)
  
  /*
!  * Bit in flags telling driver to set disksort disable flag from ssd.conf
!  * ssd-config-list and driver table.
   */
  #define SD_CONF_SET_DISKSORT_DISABLED   16
  #define SD_CONF_BSET_DISKSORT_DISABLED  (1 << SD_CONF_SET_DISKSORT_DISABLED)
  
  /*
!  * Bit in flags telling driver to set LUN Reset enable flag from [s]sd.conf
!  * [s]sd-config-list and driver table.
   */
  #define SD_CONF_SET_LUN_RESET_ENABLED   17
  #define SD_CONF_BSET_LUN_RESET_ENABLED  (1 << SD_CONF_SET_LUN_RESET_ENABLED)
  
  /*
--- 1917,1942 ----
   */
  #define SD_CONF_SET_TUR_CHECK           14
  #define SD_CONF_BSET_TUR_CHECK          (1 << SD_CONF_SET_TUR_CHECK)
  
  /*
!  * Bit in flags telling driver to set min. throttle from sd.conf
!  * sd-config-list and driver table.
   */
  #define SD_CONF_SET_MIN_THROTTLE        15
  #define SD_CONF_BSET_MIN_THROTTLE       (1 << SD_CONF_SET_MIN_THROTTLE)
  
  /*
!  * Bit in flags telling driver to set disksort disable flag from sd.conf
!  * sd-config-list and driver table.
   */
  #define SD_CONF_SET_DISKSORT_DISABLED   16
  #define SD_CONF_BSET_DISKSORT_DISABLED  (1 << SD_CONF_SET_DISKSORT_DISABLED)
  
  /*
!  * Bit in flags telling driver to set LUN Reset enable flag from sd.conf
!  * sd-config-list and driver table.
   */
  #define SD_CONF_SET_LUN_RESET_ENABLED   17
  #define SD_CONF_BSET_LUN_RESET_ENABLED  (1 << SD_CONF_SET_LUN_RESET_ENABLED)
  
  /*
*** 2061,2072 ****
   */
  #define SD_CONF_SET_CACHE_IS_NV 18
  #define SD_CONF_BSET_CACHE_IS_NV        (1 << SD_CONF_SET_CACHE_IS_NV)
  
  /*
!  * Bit in flags telling driver that the power condition flag from [s]sd.conf
!  * [s]sd-config-list and driver table.
   */
  #define SD_CONF_SET_PC_DISABLED 19
  #define SD_CONF_BSET_PC_DISABLED        (1 << SD_CONF_SET_PC_DISABLED)
  
  /*
--- 1945,1956 ----
   */
  #define SD_CONF_SET_CACHE_IS_NV         18
  #define SD_CONF_BSET_CACHE_IS_NV        (1 << SD_CONF_SET_CACHE_IS_NV)
  
  /*
!  * Bit in flags telling driver that the power condition flag from sd.conf
!  * sd-config-list and driver table.
   */
  #define SD_CONF_SET_PC_DISABLED         19
  #define SD_CONF_BSET_PC_DISABLED        (1 << SD_CONF_SET_PC_DISABLED)
  
  /*
*** 2168,2179 ****
          uchar_t bdesc_length_hi;        /* length of block descriptor(s) */
                                          /* (if any) */
          uchar_t bdesc_length_lo;
  };
  
- _NOTE(SCHEME_PROTECTS_DATA("Unshared data", mode_header_grp2))
- 
  /*
   * Length of the Mode Parameter Header for the Group 2 Mode Select command
   */
  #define MODE_HEADER_LENGTH_GRP2 (sizeof (struct mode_header_grp2))
  #define MODE_PARAM_LENGTH_GRP2 (MODE_HEADER_LENGTH_GRP2 + MODE_BLK_DESC_LENGTH)
--- 2052,2061 ----
*** 2373,2383 ****
  #define SD_VPD_UNIT_SERIAL_PG   0x02    /* 0x80 - Unit Serial Number */
  #define SD_VPD_OPERATING_PG     0x04    /* 0x81 - Implemented Op Defs */
  #define SD_VPD_ASCII_OP_PG      0x08    /* 0x82 - ASCII Op Defs */
  #define SD_VPD_DEVID_WWN_PG     0x10    /* 0x83 - Device Identification */
  #define SD_VPD_EXTENDED_DATA_PG 0x80    /* 0x86 - Extended data about the lun */
! #define SD_VPD_DEV_CHARACTER_PG 0x400   /* 0xB1 - Device Characteristics */
  
  /*
   * Non-volatile cache support
   *
   * Bit 1 of the byte 6 in the Extended INQUIRY data VPD page
--- 2255,2266 ----
  #define SD_VPD_UNIT_SERIAL_PG   0x02    /* 0x80 - Unit Serial Number */
  #define SD_VPD_OPERATING_PG     0x04    /* 0x81 - Implemented Op Defs */
  #define SD_VPD_ASCII_OP_PG      0x08    /* 0x82 - ASCII Op Defs */
  #define SD_VPD_DEVID_WWN_PG     0x10    /* 0x83 - Device Identification */
  #define SD_VPD_EXTENDED_DATA_PG 0x80    /* 0x86 - Extended data about the lun */
! #define SD_VPD_BLK_LIMITS_PG    0x400   /* 0xB0 - Block Limits */
! #define SD_VPD_DEV_CHARACTER_PG 0x800   /* 0xB1 - Device Characteristics */
  
  /*
   * Non-volatile cache support
   *
   * Bit 1 of the byte 6 in the Extended INQUIRY data VPD page
*** 2392,2414 ****
   * caches.
   */
  #define SD_VPD_NV_SUP   0x02
  #define SD_SYNC_NV_BIT 0x04
  
- /*
-  * Addition from sddef.intel.h
-  */
- #if defined(__i386) || defined(__amd64)
- 
- #define P0_RAW_DISK     (NDKMAP)
- #define FDISK_P1        (NDKMAP+1)
- #define FDISK_P2        (NDKMAP+2)
- #define FDISK_P3        (NDKMAP+3)
- #define FDISK_P4        (NDKMAP+4)
- 
- #endif  /* __i386 || __amd64 */
- 
  #ifdef  __cplusplus
  }
  #endif
  
  
--- 2275,2284 ----