diff options
author | mjacob <mjacob@FreeBSD.org> | 2006-10-31 05:53:29 +0000 |
---|---|---|
committer | mjacob <mjacob@FreeBSD.org> | 2006-10-31 05:53:29 +0000 |
commit | 7e1db24f987a0a59d6a2ddc84ab0ef69d9d0370e (patch) | |
tree | 8b3b2da053646664eaa8096add01ca22cc513072 /sys/dev/aic | |
parent | 21803ea6f1397d03bf63a4e7bf9f4aac1f9f505d (diff) | |
download | FreeBSD-src-7e1db24f987a0a59d6a2ddc84ab0ef69d9d0370e.zip FreeBSD-src-7e1db24f987a0a59d6a2ddc84ab0ef69d9d0370e.tar.gz |
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
Diffstat (limited to 'sys/dev/aic')
-rw-r--r-- | sys/dev/aic/aic.c | 127 |
1 files changed, 117 insertions, 10 deletions
diff --git a/sys/dev/aic/aic.c b/sys/dev/aic/aic.c index b09d3e8..c912153 100644 --- a/sys/dev/aic/aic.c +++ b/sys/dev/aic/aic.c @@ -165,14 +165,56 @@ aic_action(struct cam_sim *sim, union ccb *ccb) } case XPT_SET_TRAN_SETTINGS: { - struct ccb_trans_settings *cts; - struct aic_tinfo *ti; - - cts = &ccb->cts; - ti = &aic->tinfo[ccb->ccb_h.target_id]; + struct ccb_trans_settings *cts = cts = &ccb->cts; + struct aic_tinfo *ti = &aic->tinfo[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; s = splcam(); + if ((spi->valid & CTS_SPI_VALID_DISC) != 0 && + (aic->flags & AIC_DISC_ENABLE) != 0) { + if ((spi->flags & CTS_SPI_FLAGS_DISC_ENB) != 0) + ti->flags |= TINFO_DISC_ENB; + else + ti->flags &= ~TINFO_DISC_ENB; + } + + if ((scsi->valid & CTS_SCSI_VALID_TQ) != 0) { + if ((scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) != 0) + ti->flags |= TINFO_TAG_ENB; + else + ti->flags &= ~TINFO_TAG_ENB; + } + + if ((spi->valid & CTS_SPI_VALID_SYNC_RATE) != 0) { + ti->goal.period = spi->sync_period; + + if (ti->goal.period > aic->min_period) { + ti->goal.period = 0; + ti->goal.offset = 0; + } else if (ti->goal.period < aic->max_period) + ti->goal.period = aic->max_period; + } + + if ((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) != 0) { + ti->goal.offset = spi->sync_offset; + if (ti->goal.offset == 0) + ti->goal.period = 0; + else if (ti->goal.offset > AIC_SYNC_OFFSET) + ti->goal.offset = AIC_SYNC_OFFSET; + } + + if ((ti->goal.period != ti->current.period) + || (ti->goal.offset != ti->current.offset)) + ti->flags |= TINFO_SDTR_NEGO; + + splx(s); +#else + s = splcam(); if ((cts->valid & CCB_TRANS_DISC_VALID) != 0 && (aic->flags & AIC_DISC_ENABLE) != 0) { if ((cts->flags & CCB_TRANS_DISC_ENB) != 0) @@ -211,20 +253,51 @@ aic_action(struct cam_sim *sim, union ccb *ccb) ti->flags |= TINFO_SDTR_NEGO; splx(s); +#endif ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); break; } case XPT_GET_TRAN_SETTINGS: { - struct ccb_trans_settings *cts; - struct aic_tinfo *ti; - - cts = &ccb->cts; - ti = &aic->tinfo[ccb->ccb_h.target_id]; + struct ccb_trans_settings *cts = &ccb->cts; + struct aic_tinfo *ti = &aic->tinfo[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; + scsi->flags &= ~CTS_SCSI_FLAGS_TAG_ENB; + spi->flags &= ~CTS_SPI_FLAGS_DISC_ENB; s = splcam(); + if ((ti->flags & TINFO_DISC_ENB) != 0) + spi->flags |= CTS_SPI_FLAGS_DISC_ENB; + if ((ti->flags & TINFO_TAG_ENB) != 0) + scsi->flags |= CTS_SCSI_FLAGS_TAG_ENB; + if (cts->type == CTS_TYPE_CURRENT_SETTINGS) { + spi->sync_period = ti->current.period; + spi->sync_offset = ti->current.offset; + } else { + spi->sync_period = ti->user.period; + spi->sync_offset = ti->user.offset; + } + splx(s); + + spi->bus_width = MSG_EXT_WDTR_BUS_8_BIT; + 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 + s = splcam(); cts->flags &= ~(CCB_TRANS_DISC_ENB|CCB_TRANS_TAG_ENB); if ((ti->flags & TINFO_DISC_ENB) != 0) cts->flags |= CCB_TRANS_DISC_ENB; @@ -247,6 +320,7 @@ aic_action(struct cam_sim *sim, union ccb *ccb) | CCB_TRANS_BUS_WIDTH_VALID | CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID; +#endif ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); @@ -281,6 +355,12 @@ aic_action(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; @@ -598,6 +678,9 @@ aic_handle_msgin(struct aic_softc *aic) struct ccb_hdr *ccb_h; struct aic_tinfo *ti; struct ccb_trans_settings neg; +#ifdef CAM_NEW_TRAN_CODE + struct ccb_trans_settings_spi *spi = &neg.xport_specific.spi; +#endif if (aic->state == AIC_RESELECTED) { if (!MSG_ISIDENTIFY(aic->msg_buf[0])) { @@ -683,10 +766,22 @@ aic_handle_msgin(struct aic_softc *aic) ti->scsirate = ti->current.offset ? ti->current.offset | ((ti->current.period * 4 + 49) / 50 - 2) << 4 : 0; aic_outb(aic, SCSIRATE, ti->scsirate); + memset(&neg, 0, sizeof (neg)); +#ifdef CAM_NEW_TRAN_CODE + neg.protocol = PROTO_SCSI; + neg.protocol_version = SCSI_REV_2; + neg.transport = XPORT_SPI; + neg.transport_version = 2; + spi->sync_period = ti->goal.period = ti->current.period; + spi->sync_offset = ti->goal.offset = ti->current.offset; + spi->valid = CTS_SPI_VALID_SYNC_RATE + | CTS_SPI_VALID_SYNC_OFFSET; +#else neg.sync_period = ti->goal.period = ti->current.period; neg.sync_offset = ti->goal.offset = ti->current.offset; neg.valid = CCB_TRANS_SYNC_RATE_VALID | CCB_TRANS_SYNC_OFFSET_VALID; +#endif ccb_h = &scb->ccb->ccb_h; xpt_setup_ccb(&neg.ccb_h, ccb_h->path, 1); xpt_async(AC_TRANSFER_NEG, ccb_h->path, &neg); @@ -722,10 +817,22 @@ aic_handle_msgin(struct aic_softc *aic) ti->flags &= ~(TINFO_SDTR_SENT|TINFO_SDTR_NEGO); ti->scsirate = 0; aic_outb(aic, SCSIRATE, ti->scsirate); + memset(&neg, 0, sizeof (neg)); +#ifdef CAM_NEW_TRAN_CODE + neg.protocol = PROTO_SCSI; + neg.protocol_version = SCSI_REV_2; + neg.transport = XPORT_SPI; + neg.transport_version = 2; + spi->sync_period = ti->current.period; + spi->sync_offset = ti->current.offset; + spi->valid = CTS_SPI_VALID_SYNC_RATE + | CTS_SPI_VALID_SYNC_OFFSET; +#else neg.sync_period = ti->current.period; neg.sync_offset = ti->current.offset; neg.valid = CCB_TRANS_SYNC_RATE_VALID | CCB_TRANS_SYNC_OFFSET_VALID; +#endif ccb_h = &scb->ccb->ccb_h; xpt_setup_ccb(&neg.ccb_h, ccb_h->path, 1); xpt_async(AC_TRANSFER_NEG, ccb_h->path, &neg); |