246
247 static int sd_dtype_optical_bind = -1;
248
249 /* Note: the following is not a bug, it really is "sd_" and not "ssd_" */
250 static char *sd_resv_conflict_name = "sd_retry_on_reservation_conflict";
251
252 /*
253 * Global data for debug logging. To enable debug printing, sd_component_mask
254 * and sd_level_mask should be set to the desired bit patterns as outlined in
255 * sddef.h.
256 */
257 uint_t sd_component_mask = 0x0;
258 uint_t sd_level_mask = 0x0;
259 struct sd_lun *sd_debug_un = NULL;
260 uint_t sd_error_level = SCSI_ERR_RETRYABLE;
261
262 /* Note: these may go away in the future... */
263 static uint32_t sd_xbuf_active_limit = 512;
264 static uint32_t sd_xbuf_reserve_limit = 16;
265
266 static struct sd_resv_reclaim_request sd_tr = { NULL, NULL, NULL, 0, 0, 0 };
267
268 /*
269 * Timer value used to reset the throttle after it has been reduced
270 * (typically in response to TRAN_BUSY or STATUS_QFULL)
271 */
272 static int sd_reset_throttle_timeout = SD_RESET_THROTTLE_TIMEOUT;
273 static int sd_qfull_throttle_timeout = SD_QFULL_THROTTLE_TIMEOUT;
274
275 /*
276 * Interval value associated with the media change scsi watch.
277 */
278 static int sd_check_media_time = 3000000;
279
280 /*
281 * Wait value used for in progress operations during a DDI_SUSPEND
282 */
283 static int sd_wait_cmds_complete = SD_WAIT_CMDS_COMPLETE;
284
285 /*
286 * sd_label_mutex protects a static buffer used in the disk label
817 #define SD_INTERCONNECT_PARALLEL 0
818 #define SD_INTERCONNECT_FABRIC 1
819 #define SD_INTERCONNECT_FIBRE 2
820 #define SD_INTERCONNECT_SSA 3
821 #define SD_INTERCONNECT_SATA 4
822 #define SD_INTERCONNECT_SAS 5
823
824 #define SD_IS_PARALLEL_SCSI(un) \
825 ((un)->un_interconnect_type == SD_INTERCONNECT_PARALLEL)
826 #define SD_IS_SERIAL(un) \
827 (((un)->un_interconnect_type == SD_INTERCONNECT_SATA) ||\
828 ((un)->un_interconnect_type == SD_INTERCONNECT_SAS))
829
830 /*
831 * Definitions used by device id registration routines
832 */
833 #define VPD_HEAD_OFFSET 3 /* size of head for vpd page */
834 #define VPD_PAGE_LENGTH 3 /* offset for pge length data */
835 #define VPD_MODE_PAGE 1 /* offset into vpd pg for "page code" */
836
837 static kmutex_t sd_sense_mutex = {0};
838
839 /*
840 * Macros for updates of the driver state
841 */
842 #define New_state(un, s) \
843 (un)->un_last_state = (un)->un_state, (un)->un_state = (s)
844 #define Restore_state(un) \
845 { uchar_t tmp = (un)->un_last_state; New_state((un), tmp); }
846
847 static struct sd_cdbinfo sd_cdbtab[] = {
848 { CDB_GROUP0, 0x00, 0x1FFFFF, 0xFF, },
849 { CDB_GROUP1, SCMD_GROUP1, 0xFFFFFFFF, 0xFFFF, },
850 { CDB_GROUP5, SCMD_GROUP5, 0xFFFFFFFF, 0xFFFFFFFF, },
851 { CDB_GROUP4, SCMD_GROUP4, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFF, },
852 };
853
854 /*
855 * Specifies the number of seconds that must have elapsed since the last
856 * cmd. has completed for a device to be declared idle to the PM framework.
857 */
1754 nodev, /* reset */
1755 &sd_cb_ops, /* driver operations */
1756 NULL, /* bus operations */
1757 sdpower, /* power */
1758 ddi_quiesce_not_needed, /* quiesce */
1759 };
1760
1761 /*
1762 * This is the loadable module wrapper.
1763 */
1764 #include <sys/modctl.h>
1765
1766 #ifndef XPV_HVM_DRIVER
1767 static struct modldrv modldrv = {
1768 &mod_driverops, /* Type of module. This one is a driver */
1769 SD_MODULE_NAME, /* Module name. */
1770 &sd_ops /* driver ops */
1771 };
1772
1773 static struct modlinkage modlinkage = {
1774 MODREV_1, &modldrv, NULL
1775 };
1776
1777 #else /* XPV_HVM_DRIVER */
1778 static struct modlmisc modlmisc = {
1779 &mod_miscops, /* Type of module. This one is a misc */
1780 "HVM " SD_MODULE_NAME, /* Module name. */
1781 };
1782
1783 static struct modlinkage modlinkage = {
1784 MODREV_1, &modlmisc, NULL
1785 };
1786
1787 #endif /* XPV_HVM_DRIVER */
1788
1789 static cmlb_tg_ops_t sd_tgops = {
1790 TG_DK_OPS_VERSION_1,
1791 sd_tg_rdwr,
1792 sd_tg_getinfo
1793 };
1794
1795 static struct scsi_asq_key_strings sd_additional_codes[] = {
1796 0x81, 0, "Logical Unit is Reserved",
1797 0x85, 0, "Audio Address Not Valid",
1798 0xb6, 0, "Media Load Mechanism Failed",
1799 0xB9, 0, "Audio Play Operation Aborted",
1800 0xbf, 0, "Buffer Overflow for Read All Subcodes Command",
1801 0x53, 2, "Medium removal prevented",
1802 0x6f, 0, "Authentication failed during key exchange",
1803 0x6f, 1, "Key not present",
1804 0x6f, 2, "Key not established",
1805 0x6f, 3, "Read without proper authentication",
1806 0x6f, 4, "Mismatched region to this logical unit",
1807 0x6f, 5, "Region reset count error",
1808 0xffff, 0x0, NULL
1809 };
1810
1811
1812 /*
1813 * Struct for passing printing information for sense data messages
1814 */
1815 struct sd_sense_info {
1816 int ssi_severity;
1817 int ssi_pfa_flag;
1818 };
1819
1820 /*
1821 * Table of function pointers for iostart-side routines. Separate "chains"
1822 * of layered function calls are formed by placing the function pointers
1823 * sequentially in the desired order. Functions are called according to an
1824 * incrementing table index ordering. The last function in each chain must
1825 * be sd_core_iostart(). The corresponding iodone-side routines are expected
1826 * in the sd_iodone_chain[] array.
1827 *
1828 * Note: It may seem more natural to organize both the iostart and iodone
|
246
247 static int sd_dtype_optical_bind = -1;
248
249 /* Note: the following is not a bug, it really is "sd_" and not "ssd_" */
250 static char *sd_resv_conflict_name = "sd_retry_on_reservation_conflict";
251
252 /*
253 * Global data for debug logging. To enable debug printing, sd_component_mask
254 * and sd_level_mask should be set to the desired bit patterns as outlined in
255 * sddef.h.
256 */
257 uint_t sd_component_mask = 0x0;
258 uint_t sd_level_mask = 0x0;
259 struct sd_lun *sd_debug_un = NULL;
260 uint_t sd_error_level = SCSI_ERR_RETRYABLE;
261
262 /* Note: these may go away in the future... */
263 static uint32_t sd_xbuf_active_limit = 512;
264 static uint32_t sd_xbuf_reserve_limit = 16;
265
266 static struct sd_resv_reclaim_request sd_tr = { NULL, NULL, NULL, {0} };
267
268 /*
269 * Timer value used to reset the throttle after it has been reduced
270 * (typically in response to TRAN_BUSY or STATUS_QFULL)
271 */
272 static int sd_reset_throttle_timeout = SD_RESET_THROTTLE_TIMEOUT;
273 static int sd_qfull_throttle_timeout = SD_QFULL_THROTTLE_TIMEOUT;
274
275 /*
276 * Interval value associated with the media change scsi watch.
277 */
278 static int sd_check_media_time = 3000000;
279
280 /*
281 * Wait value used for in progress operations during a DDI_SUSPEND
282 */
283 static int sd_wait_cmds_complete = SD_WAIT_CMDS_COMPLETE;
284
285 /*
286 * sd_label_mutex protects a static buffer used in the disk label
817 #define SD_INTERCONNECT_PARALLEL 0
818 #define SD_INTERCONNECT_FABRIC 1
819 #define SD_INTERCONNECT_FIBRE 2
820 #define SD_INTERCONNECT_SSA 3
821 #define SD_INTERCONNECT_SATA 4
822 #define SD_INTERCONNECT_SAS 5
823
824 #define SD_IS_PARALLEL_SCSI(un) \
825 ((un)->un_interconnect_type == SD_INTERCONNECT_PARALLEL)
826 #define SD_IS_SERIAL(un) \
827 (((un)->un_interconnect_type == SD_INTERCONNECT_SATA) ||\
828 ((un)->un_interconnect_type == SD_INTERCONNECT_SAS))
829
830 /*
831 * Definitions used by device id registration routines
832 */
833 #define VPD_HEAD_OFFSET 3 /* size of head for vpd page */
834 #define VPD_PAGE_LENGTH 3 /* offset for pge length data */
835 #define VPD_MODE_PAGE 1 /* offset into vpd pg for "page code" */
836
837 static kmutex_t sd_sense_mutex = {{NULL}};
838
839 /*
840 * Macros for updates of the driver state
841 */
842 #define New_state(un, s) \
843 (un)->un_last_state = (un)->un_state, (un)->un_state = (s)
844 #define Restore_state(un) \
845 { uchar_t tmp = (un)->un_last_state; New_state((un), tmp); }
846
847 static struct sd_cdbinfo sd_cdbtab[] = {
848 { CDB_GROUP0, 0x00, 0x1FFFFF, 0xFF, },
849 { CDB_GROUP1, SCMD_GROUP1, 0xFFFFFFFF, 0xFFFF, },
850 { CDB_GROUP5, SCMD_GROUP5, 0xFFFFFFFF, 0xFFFFFFFF, },
851 { CDB_GROUP4, SCMD_GROUP4, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFF, },
852 };
853
854 /*
855 * Specifies the number of seconds that must have elapsed since the last
856 * cmd. has completed for a device to be declared idle to the PM framework.
857 */
1754 nodev, /* reset */
1755 &sd_cb_ops, /* driver operations */
1756 NULL, /* bus operations */
1757 sdpower, /* power */
1758 ddi_quiesce_not_needed, /* quiesce */
1759 };
1760
1761 /*
1762 * This is the loadable module wrapper.
1763 */
1764 #include <sys/modctl.h>
1765
1766 #ifndef XPV_HVM_DRIVER
1767 static struct modldrv modldrv = {
1768 &mod_driverops, /* Type of module. This one is a driver */
1769 SD_MODULE_NAME, /* Module name. */
1770 &sd_ops /* driver ops */
1771 };
1772
1773 static struct modlinkage modlinkage = {
1774 MODREV_1, { &modldrv, NULL }
1775 };
1776
1777 #else /* XPV_HVM_DRIVER */
1778 static struct modlmisc modlmisc = {
1779 &mod_miscops, /* Type of module. This one is a misc */
1780 "HVM " SD_MODULE_NAME, /* Module name. */
1781 };
1782
1783 static struct modlinkage modlinkage = {
1784 MODREV_1, { &modlmisc, NULL }
1785 };
1786
1787 #endif /* XPV_HVM_DRIVER */
1788
1789 static cmlb_tg_ops_t sd_tgops = {
1790 TG_DK_OPS_VERSION_1,
1791 sd_tg_rdwr,
1792 sd_tg_getinfo
1793 };
1794
1795 static struct scsi_asq_key_strings sd_additional_codes[] = {
1796 { 0x81, 0, "Logical Unit is Reserved" },
1797 { 0x85, 0, "Audio Address Not Valid" },
1798 { 0xb6, 0, "Media Load Mechanism Failed" },
1799 { 0xB9, 0, "Audio Play Operation Aborted" },
1800 { 0xbf, 0, "Buffer Overflow for Read All Subcodes Command" },
1801 { 0x53, 2, "Medium removal prevented" },
1802 { 0x6f, 0, "Authentication failed during key exchange" },
1803 { 0x6f, 1, "Key not present" },
1804 { 0x6f, 2, "Key not established" },
1805 { 0x6f, 3, "Read without proper authentication" },
1806 { 0x6f, 4, "Mismatched region to this logical unit" },
1807 { 0x6f, 5, "Region reset count error" },
1808 { 0xffff, 0x0, NULL }
1809 };
1810
1811
1812 /*
1813 * Struct for passing printing information for sense data messages
1814 */
1815 struct sd_sense_info {
1816 int ssi_severity;
1817 int ssi_pfa_flag;
1818 };
1819
1820 /*
1821 * Table of function pointers for iostart-side routines. Separate "chains"
1822 * of layered function calls are formed by placing the function pointers
1823 * sequentially in the desired order. Functions are called according to an
1824 * incrementing table index ordering. The last function in each chain must
1825 * be sd_core_iostart(). The corresponding iodone-side routines are expected
1826 * in the sd_iodone_chain[] array.
1827 *
1828 * Note: It may seem more natural to organize both the iostart and iodone
|