1119 #define SDIOCINSERTARQ (SDIOC|6)
1120 #define SDIOCPUSH (SDIOC|7)
1121 #define SDIOCRETRIEVE (SDIOC|8)
1122 #define SDIOCRUN (SDIOC|9)
1123 #endif
1124
1125 #else
1126
1127 #undef SDDEBUG
1128 #define SD_ERROR { if (0) sd_log_err; }
1129 #define SD_TRACE { if (0) sd_log_trace; }
1130 #define SD_INFO { if (0) sd_log_info; }
1131 #define SD_DUMP_MEMORY { if (0) sd_dump_memory; }
1132 #endif
1133
1134
1135 /*
1136 * Miscellaneous macros
1137 */
1138
1139 #define SD_USECTOHZ(x) (drv_usectohz((x)*1000000))
1140 #define SD_GET_PKT_STATUS(pktp) ((*(pktp)->pkt_scbp) & STATUS_MASK)
1141
1142 #define SD_BIOERROR(bp, errcode) \
1143 if ((bp)->b_resid == 0) { \
1144 (bp)->b_resid = (bp)->b_bcount; \
1145 } \
1146 if ((bp)->b_error == 0) { \
1147 bioerror(bp, errcode); \
1148 } \
1149 (bp)->b_flags |= B_ERROR;
1150
1151 #define SD_FILL_SCSI1_LUN_CDB(lunp, cdbp) \
1152 if (! (lunp)->un_f_is_fibre && \
1153 SD_INQUIRY((lunp))->inq_ansi == 0x01) { \
1154 int _lun = ddi_prop_get_int(DDI_DEV_T_ANY, \
1155 SD_DEVINFO((lunp)), DDI_PROP_DONTPASS, \
1156 SCSI_ADDR_PROP_LUN, 0); \
1157 if (_lun > 0) { \
1158 (cdbp)->scc_lun = _lun; \
1159 } \
1299 } \
1300 }
1301
1302 #define SD_SENSE_DATA_IS_VALID 0
1303 #define SD_SENSE_DATA_IS_INVALID 1
1304
1305 /*
1306 * Delay (in seconds) before restoring the "throttle limit" back
1307 * to its maximum value.
1308 * 60 seconds is what we will wait for to reset the
1309 * throttle back to it SD_MAX_THROTTLE for TRAN_BUSY.
1310 * 10 seconds for STATUS_QFULL because QFULL will incrementally
1311 * increase the throttle limit until it reaches max value.
1312 */
1313 #define SD_RESET_THROTTLE_TIMEOUT 60
1314 #define SD_QFULL_THROTTLE_TIMEOUT 10
1315
1316 #define SD_THROTTLE_TRAN_BUSY 0
1317 #define SD_THROTTLE_QFULL 1
1318
1319 #define SD_THROTTLE_RESET_INTERVAL \
1320 (sd_reset_throttle_timeout * drv_usectohz(1000000))
1321
1322 #define SD_QFULL_THROTTLE_RESET_INTERVAL \
1323 (sd_qfull_throttle_timeout * drv_usectohz(1000000))
1324
1325
1326 /*
1327 * xb_pkt_flags defines
1328 * SD_XB_DMA_FREED indicates the scsi_pkt has had its DMA resources freed
1329 * by a call to scsi_dmafree(9F). The resources must be reallocated before
1330 * before a call to scsi_transport can be made again.
1331 * SD_XB_USCSICMD indicates the scsi request is a uscsi request
1332 * SD_XB_INITPKT_MASK: since this field is also used to store flags for
1333 * a scsi_init_pkt(9F) call, we need a mask to make sure that we don't
1334 * pass any unintended bits to scsi_init_pkt(9F) (ugly hack).
1335 */
1336 #define SD_XB_DMA_FREED 0x20000000
1337 #define SD_XB_USCSICMD 0x40000000
1338 #define SD_XB_INITPKT_MASK (PKT_CONSISTENT | PKT_DMA_PARTIAL)
1339
1340 /*
1341 * Extension for the buf(9s) struct that we receive from a higher
1342 * layer. Located by b_private in the buf(9S). (The previous contents
1343 * of b_private are saved & restored before calling biodone(9F).)
1699 }
1700
1701
1702 #endif /* defined(_KERNEL) || defined(_KMEMUSER) */
1703
1704
1705 /*
1706 * 60 seconds is a *very* reasonable amount of time for most slow CD
1707 * operations.
1708 */
1709 #define SD_IO_TIME 60
1710
1711 /*
1712 * 2 hours is an excessively reasonable amount of time for format operations.
1713 */
1714 #define SD_FMT_TIME (120 * 60)
1715
1716 /*
1717 * 5 seconds is what we'll wait if we get a Busy Status back
1718 */
1719 #define SD_BSY_TIMEOUT (drv_usectohz(5 * 1000000))
1720
1721 /*
1722 * 100 msec. is what we'll wait if we get Unit Attention.
1723 */
1724 #define SD_UA_RETRY_DELAY (drv_usectohz((clock_t)100000))
1725
1726 /*
1727 * 100 msec. is what we'll wait for restarted commands.
1728 */
1729 #define SD_RESTART_TIMEOUT (drv_usectohz((clock_t)100000))
1730
1731 /*
1732 * 10s misaligned I/O warning message interval
1733 */
1734 #define SD_RMW_MSG_PRINT_TIMEOUT (drv_usectohz((clock_t)10000000))
1735
1736 /*
1737 * 100 msec. is what we'll wait for certain retries for fibre channel
1738 * targets, 0 msec for parallel SCSI.
1739 */
1740 #if defined(__fibre)
1741 #define SD_RETRY_DELAY (drv_usectohz(100000))
1742 #else
1743 #define SD_RETRY_DELAY ((clock_t)0)
1744 #endif
1745
1746 /*
1747 * 60 seconds is what we will wait for to reset the
1748 * throttle back to it SD_MAX_THROTTLE.
1749 */
1750 #define SD_RESET_THROTTLE_TIMEOUT 60
1751
1752 /*
1753 * Number of times we'll retry a normal operation.
1754 *
|
1119 #define SDIOCINSERTARQ (SDIOC|6)
1120 #define SDIOCPUSH (SDIOC|7)
1121 #define SDIOCRETRIEVE (SDIOC|8)
1122 #define SDIOCRUN (SDIOC|9)
1123 #endif
1124
1125 #else
1126
1127 #undef SDDEBUG
1128 #define SD_ERROR { if (0) sd_log_err; }
1129 #define SD_TRACE { if (0) sd_log_trace; }
1130 #define SD_INFO { if (0) sd_log_info; }
1131 #define SD_DUMP_MEMORY { if (0) sd_dump_memory; }
1132 #endif
1133
1134
1135 /*
1136 * Miscellaneous macros
1137 */
1138
1139 #define SD_GET_PKT_STATUS(pktp) ((*(pktp)->pkt_scbp) & STATUS_MASK)
1140
1141 #define SD_BIOERROR(bp, errcode) \
1142 if ((bp)->b_resid == 0) { \
1143 (bp)->b_resid = (bp)->b_bcount; \
1144 } \
1145 if ((bp)->b_error == 0) { \
1146 bioerror(bp, errcode); \
1147 } \
1148 (bp)->b_flags |= B_ERROR;
1149
1150 #define SD_FILL_SCSI1_LUN_CDB(lunp, cdbp) \
1151 if (! (lunp)->un_f_is_fibre && \
1152 SD_INQUIRY((lunp))->inq_ansi == 0x01) { \
1153 int _lun = ddi_prop_get_int(DDI_DEV_T_ANY, \
1154 SD_DEVINFO((lunp)), DDI_PROP_DONTPASS, \
1155 SCSI_ADDR_PROP_LUN, 0); \
1156 if (_lun > 0) { \
1157 (cdbp)->scc_lun = _lun; \
1158 } \
1298 } \
1299 }
1300
1301 #define SD_SENSE_DATA_IS_VALID 0
1302 #define SD_SENSE_DATA_IS_INVALID 1
1303
1304 /*
1305 * Delay (in seconds) before restoring the "throttle limit" back
1306 * to its maximum value.
1307 * 60 seconds is what we will wait for to reset the
1308 * throttle back to it SD_MAX_THROTTLE for TRAN_BUSY.
1309 * 10 seconds for STATUS_QFULL because QFULL will incrementally
1310 * increase the throttle limit until it reaches max value.
1311 */
1312 #define SD_RESET_THROTTLE_TIMEOUT 60
1313 #define SD_QFULL_THROTTLE_TIMEOUT 10
1314
1315 #define SD_THROTTLE_TRAN_BUSY 0
1316 #define SD_THROTTLE_QFULL 1
1317
1318 #define SD_THROTTLE_RESET_INTERVAL drv_sectohz(sd_reset_throttle_timeout)
1319
1320 #define SD_QFULL_THROTTLE_RESET_INTERVAL \
1321 drv_sectohz(sd_qfull_throttle_timeout)
1322
1323
1324 /*
1325 * xb_pkt_flags defines
1326 * SD_XB_DMA_FREED indicates the scsi_pkt has had its DMA resources freed
1327 * by a call to scsi_dmafree(9F). The resources must be reallocated before
1328 * before a call to scsi_transport can be made again.
1329 * SD_XB_USCSICMD indicates the scsi request is a uscsi request
1330 * SD_XB_INITPKT_MASK: since this field is also used to store flags for
1331 * a scsi_init_pkt(9F) call, we need a mask to make sure that we don't
1332 * pass any unintended bits to scsi_init_pkt(9F) (ugly hack).
1333 */
1334 #define SD_XB_DMA_FREED 0x20000000
1335 #define SD_XB_USCSICMD 0x40000000
1336 #define SD_XB_INITPKT_MASK (PKT_CONSISTENT | PKT_DMA_PARTIAL)
1337
1338 /*
1339 * Extension for the buf(9s) struct that we receive from a higher
1340 * layer. Located by b_private in the buf(9S). (The previous contents
1341 * of b_private are saved & restored before calling biodone(9F).)
1697 }
1698
1699
1700 #endif /* defined(_KERNEL) || defined(_KMEMUSER) */
1701
1702
1703 /*
1704 * 60 seconds is a *very* reasonable amount of time for most slow CD
1705 * operations.
1706 */
1707 #define SD_IO_TIME 60
1708
1709 /*
1710 * 2 hours is an excessively reasonable amount of time for format operations.
1711 */
1712 #define SD_FMT_TIME (120 * 60)
1713
1714 /*
1715 * 5 seconds is what we'll wait if we get a Busy Status back
1716 */
1717 #define SD_BSY_TIMEOUT drv_sectohz(5)
1718
1719 /*
1720 * 100 msec. is what we'll wait if we get Unit Attention.
1721 */
1722 #define SD_UA_RETRY_DELAY (drv_usectohz((clock_t)100000))
1723
1724 /*
1725 * 100 msec. is what we'll wait for restarted commands.
1726 */
1727 #define SD_RESTART_TIMEOUT (drv_usectohz((clock_t)100000))
1728
1729 /*
1730 * 10s misaligned I/O warning message interval
1731 */
1732 #define SD_RMW_MSG_PRINT_TIMEOUT drv_sectohz(10)
1733
1734 /*
1735 * 100 msec. is what we'll wait for certain retries for fibre channel
1736 * targets, 0 msec for parallel SCSI.
1737 */
1738 #if defined(__fibre)
1739 #define SD_RETRY_DELAY (drv_usectohz(100000))
1740 #else
1741 #define SD_RETRY_DELAY ((clock_t)0)
1742 #endif
1743
1744 /*
1745 * 60 seconds is what we will wait for to reset the
1746 * throttle back to it SD_MAX_THROTTLE.
1747 */
1748 #define SD_RESET_THROTTLE_TIMEOUT 60
1749
1750 /*
1751 * Number of times we'll retry a normal operation.
1752 *
|