aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/aha
diff options
context:
space:
mode:
authorMatt Jacob <mjacob@FreeBSD.org>2006-10-31 05:53:29 +0000
committerMatt Jacob <mjacob@FreeBSD.org>2006-10-31 05:53:29 +0000
commitfa9ed865067ef325f013a8174c94eff345a4f4ed (patch)
tree8b3b2da053646664eaa8096add01ca22cc513072 /sys/dev/aha
parent9df92bda761535b468b198dc0bc23dc059051e8a (diff)
downloadsrc-fa9ed865067ef325f013a8174c94eff345a4f4ed.tar.gz
src-fa9ed865067ef325f013a8174c94eff345a4f4ed.zip
The first of 3 major steps to move the CAM layer forward to using
the CAM_NEW_TRAN_CODE that has been in the tree for some years now. This first step consists solely of adding to or correcting CAM_NEW_TRAN_CODE pieces in the kernel source tree such that a both a GENERIC (at least on i386) and a LINT build with CAM_NEW_TRAN_CODE as an option will compile correctly and run (at least with some the h/w I have). After a short settle time, the other pieces (making CAM_NEW_TRAN_CODE the default and updating libcam and camcontrol) will be brought in. This will be an incompatible change in that the size of structures related to XPT_PATH_INQ and XPT_{GET,SET}_TRAN_SETTINGS change in both size and content. However, basic system operation and basic system utilities work well enough with this change. Reviewed by: freebsd-scsi and specific stakeholders
Notes
Notes: svn path=/head/; revision=163816
Diffstat (limited to 'sys/dev/aha')
-rw-r--r--sys/dev/aha/aha.c76
1 files changed, 72 insertions, 4 deletions
diff --git a/sys/dev/aha/aha.c b/sys/dev/aha/aha.c
index b828a9daf84c..6678e1c39599 100644
--- a/sys/dev/aha/aha.c
+++ b/sys/dev/aha/aha.c
@@ -899,11 +899,44 @@ ahaaction(struct cam_sim *sim, union ccb *ccb)
case XPT_GET_TRAN_SETTINGS:
/* Get default/user set transfer settings for the target */
{
- struct ccb_trans_settings *cts;
- u_int target_mask;
+ struct ccb_trans_settings *cts = &ccb->cts;
+ u_int target_mask = 0x01 << ccb->ccb_h.target_id;
+#ifdef CAM_NEW_TRAN_CODE
+ struct ccb_trans_settings_scsi *scsi =
+ &cts->proto_specific.scsi;
+ struct ccb_trans_settings_spi *spi =
+ &cts->xport_specific.spi;
+
+ cts->protocol = PROTO_SCSI;
+ cts->protocol_version = SCSI_REV_2;
+ cts->transport = XPORT_SPI;
+ cts->transport_version = 2;
+ if (cts->type == CTS_TYPE_USER_SETTINGS) {
+ spi->flags = 0;
+ if ((aha->disc_permitted & target_mask) != 0)
+ spi->flags |= CTS_SPI_FLAGS_DISC_ENB;
+ spi->bus_width = MSG_EXT_WDTR_BUS_8_BIT;
+ if ((aha->sync_permitted & target_mask) != 0) {
+ if (aha->boardid >= BOARD_1542CF)
+ spi->sync_period = 25;
+ else
+ spi->sync_period = 50;
+ } else {
+ spi->sync_period = 0;
+ }
- cts = &ccb->cts;
- target_mask = 0x01 << ccb->ccb_h.target_id;
+ if (spi->sync_period != 0)
+ spi->sync_offset = 15;
+
+ spi->valid = CTS_SPI_VALID_SYNC_RATE
+ | CTS_SPI_VALID_SYNC_OFFSET
+ | CTS_SPI_VALID_BUS_WIDTH
+ | CTS_SPI_VALID_DISC;
+ scsi->valid = CTS_SCSI_VALID_TQ;
+ } else {
+ ahafetchtransinfo(aha, cts);
+ }
+#else
if ((cts->flags & CCB_TRANS_USER_SETTINGS) != 0) {
cts->flags = 0;
if ((aha->disc_permitted & target_mask) != 0)
@@ -928,6 +961,7 @@ ahaaction(struct cam_sim *sim, union ccb *ccb)
} else {
ahafetchtransinfo(aha, cts);
}
+#endif
ccb->ccb_h.status = CAM_REQ_CMP;
xpt_done(ccb);
@@ -988,6 +1022,12 @@ ahaaction(struct cam_sim *sim, union ccb *ccb)
strncpy(cpi->hba_vid, "Adaptec", HBA_IDLEN);
strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
cpi->unit_number = cam_sim_unit(sim);
+#ifdef CAM_NEW_TRAN_CODE
+ cpi->transport = XPORT_SPI;
+ cpi->transport_version = 2;
+ cpi->protocol = PROTO_SCSI;
+ cpi->protocol_version = SCSI_REV_2;
+#endif
cpi->ccb_h.status = CAM_REQ_CMP;
xpt_done(ccb);
break;
@@ -1674,6 +1714,9 @@ ahafetchtransinfo(struct aha_softc *aha, struct ccb_trans_settings* cts)
int error;
uint8_t param;
targ_syncinfo_t sync_info;
+#ifdef CAM_NEW_TRAN_CODE
+ struct ccb_trans_settings_spi *spi = &cts->xport_specific.spi;
+#endif
target = cts->ccb_h.target_id;
targ_offset = (target & 0x7);
@@ -1695,6 +1738,30 @@ ahafetchtransinfo(struct aha_softc *aha, struct ccb_trans_settings* cts)
sync_info = setup_info.syncinfo[targ_offset];
+#ifdef CAM_NEW_TRAN_CODE
+ if (sync_info.sync == 0)
+ spi->sync_offset = 0;
+ else
+ spi->sync_offset = sync_info.offset;
+
+ spi->bus_width = MSG_EXT_WDTR_BUS_8_BIT;
+
+ if (aha->boardid >= BOARD_1542CF)
+ sync_period = 1000;
+ else
+ sync_period = 2000;
+ sync_period += 500 * sync_info.period;
+
+ /* Convert ns value to standard SCSI sync rate */
+ if (spi->sync_offset != 0)
+ spi->sync_period = scsi_calc_syncparam(sync_period);
+ else
+ spi->sync_period = 0;
+
+ spi->valid = CTS_SPI_VALID_SYNC_RATE
+ | CTS_SPI_VALID_SYNC_OFFSET
+ | CTS_SPI_VALID_BUS_WIDTH;
+#else
if (sync_info.sync == 0)
cts->sync_offset = 0;
else
@@ -1717,6 +1784,7 @@ ahafetchtransinfo(struct aha_softc *aha, struct ccb_trans_settings* cts)
cts->valid = CCB_TRANS_SYNC_RATE_VALID
| CCB_TRANS_SYNC_OFFSET_VALID
| CCB_TRANS_BUS_WIDTH_VALID;
+#endif
xpt_async(AC_TRANSFER_NEG, cts->ccb_h.path, cts);
}