diff options
| author | Matt Jacob <mjacob@FreeBSD.org> | 2006-10-31 05:53:29 +0000 |
|---|---|---|
| committer | Matt Jacob <mjacob@FreeBSD.org> | 2006-10-31 05:53:29 +0000 |
| commit | fa9ed865067ef325f013a8174c94eff345a4f4ed (patch) | |
| tree | 8b3b2da053646664eaa8096add01ca22cc513072 /sys/dev/trm | |
| parent | 9df92bda761535b468b198dc0bc23dc059051e8a (diff) | |
Notes
Diffstat (limited to 'sys/dev/trm')
| -rw-r--r-- | sys/dev/trm/trm.c | 166 |
1 files changed, 161 insertions, 5 deletions
diff --git a/sys/dev/trm/trm.c b/sys/dev/trm/trm.c index cc0cba703a94..591e7206f47d 100644 --- a/sys/dev/trm/trm.c +++ b/sys/dev/trm/trm.c @@ -711,6 +711,12 @@ trm_action(struct cam_sim *psim, union ccb *pccb) strncpy(cpi->hba_vid, "Tekram_TRM", HBA_IDLEN); strncpy(cpi->dev_name, cam_sim_name(psim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(psim); +#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(pccb); } @@ -829,13 +835,68 @@ trm_action(struct cam_sim *psim, union ccb *pccb) * (GET) default/user transfer settings for the target */ case XPT_GET_TRAN_SETTINGS: { - struct ccb_trans_settings *cts; + struct ccb_trans_settings *cts = &pccb->cts; int intflag; struct trm_transinfo *tinfo; PDCB pDCB; - +#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; + + TRM_DPRINTF(" XPT_GET_TRAN_SETTINGS \n"); + pDCB = &pACB->DCBarray[target_id][target_lun]; + intflag = splcam(); + /* + * disable interrupt + */ + if (cts->type == CTS_TYPE_CURRENT_SETTINGS) { + /* current transfer settings */ + if (pDCB->tinfo.disc_tag & TRM_CUR_DISCENB) + spi->flags = CTS_SPI_FLAGS_DISC_ENB; + else + spi->flags = 0;/* no tag & disconnect */ + if (pDCB->tinfo.disc_tag & TRM_CUR_TAGENB) + scsi->flags |= CTS_SCSI_FLAGS_TAG_ENB; + tinfo = &pDCB->tinfo.current; + TRM_DPRINTF("CURRENT: cts->flags= %2x \n", + cts->flags); + } else { + /* default(user) transfer settings */ + if (pDCB->tinfo.disc_tag & TRM_USR_DISCENB) + spi->flags = CTS_SPI_FLAGS_DISC_ENB; + else + spi->flags = 0; + if (pDCB->tinfo.disc_tag & TRM_USR_TAGENB) + scsi->flags |= CTS_SCSI_FLAGS_TAG_ENB; + tinfo = &pDCB->tinfo.user; + TRM_DPRINTF("USER: cts->flags= %2x \n", + cts->flags); + } + spi->sync_period = tinfo->period; + spi->sync_offset = tinfo->offset; + spi->bus_width = tinfo->width; + TRM_DPRINTF("pDCB->SyncPeriod: %d \n", + pDCB->SyncPeriod); + TRM_DPRINTF("period: %d \n", tinfo->period); + TRM_DPRINTF("offset: %d \n", tinfo->offset); + TRM_DPRINTF("width: %d \n", tinfo->width); + + splx(intflag); + 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 + TRM_DPRINTF(" XPT_GET_TRAN_SETTINGS \n"); - cts = &pccb->cts; pDCB = &pACB->DCBarray[target_id][target_lun]; intflag = splcam(); /* @@ -879,6 +940,7 @@ trm_action(struct cam_sim *psim, union ccb *pccb) CCB_TRANS_BUS_WIDTH_VALID | CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID; +#endif pccb->ccb_h.status = CAM_REQ_CMP; xpt_done(pccb); } @@ -889,13 +951,98 @@ trm_action(struct cam_sim *psim, union ccb *pccb) * (Set) transfer rate/width negotiation settings */ case XPT_SET_TRAN_SETTINGS: { - struct ccb_trans_settings *cts; + struct ccb_trans_settings *cts = &pccb->cts; u_int update_type; int intflag; PDCB pDCB; +#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; + + TRM_DPRINTF(" XPT_SET_TRAN_SETTINGS \n"); + update_type = 0; + if (cts->type == CTS_TYPE_CURRENT_SETTINGS) + update_type |= TRM_TRANS_GOAL; + if (cts->type == CTS_TYPE_USER_SETTINGS) + update_type |= TRM_TRANS_USER; + intflag = splcam(); + pDCB = &pACB->DCBarray[target_id][target_lun]; + + if ((spi->valid & CTS_SPI_VALID_DISC) != 0) { + /*ccb disc enables */ + if (update_type & TRM_TRANS_GOAL) { + if ((spi->flags & CTS_SPI_FLAGS_DISC_ENB) + != 0) + pDCB->tinfo.disc_tag + |= TRM_CUR_DISCENB; + else + pDCB->tinfo.disc_tag &= + ~TRM_CUR_DISCENB; + } + if (update_type & TRM_TRANS_USER) { + if ((spi->flags & CTS_SPI_FLAGS_DISC_ENB) + != 0) + pDCB->tinfo.disc_tag + |= TRM_USR_DISCENB; + else + pDCB->tinfo.disc_tag &= + ~TRM_USR_DISCENB; + } + } + if ((scsi->valid & CTS_SCSI_VALID_TQ) != 0) { + /* if ccb tag q active */ + if (update_type & TRM_TRANS_GOAL) { + if ((scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) + != 0) + pDCB->tinfo.disc_tag |= + TRM_CUR_TAGENB; + else + pDCB->tinfo.disc_tag &= + ~TRM_CUR_TAGENB; + } + if (update_type & TRM_TRANS_USER) { + if ((scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) + != 0) + pDCB->tinfo.disc_tag |= + TRM_USR_TAGENB; + else + pDCB->tinfo.disc_tag &= + ~TRM_USR_TAGENB; + } + } + /* Minimum sync period factor */ + if ((spi->valid & CTS_SPI_VALID_SYNC_RATE) != 0) { + /* if ccb sync active */ + /* TRM-S1040 MinSyncPeriod = 4 clocks/byte */ + if ((spi->sync_period != 0) && + (spi->sync_period < 125)) + spi->sync_period = 125; + /* 1/(125*4) minsync 2 MByte/sec */ + if ((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) + != 0) { + if (spi->sync_offset == 0) + spi->sync_period = 0; + /* TRM-S1040 MaxSyncOffset = 15 bytes*/ + if (spi->sync_offset > 15) + spi->sync_offset = 15; + } + } + if ((update_type & TRM_TRANS_USER) != 0) { + pDCB->tinfo.user.period = spi->sync_period; + pDCB->tinfo.user.offset = spi->sync_offset; + pDCB->tinfo.user.width = spi->bus_width; + } + if ((update_type & TRM_TRANS_GOAL) != 0) { + pDCB->tinfo.goal.period = spi->sync_period; + pDCB->tinfo.goal.offset = spi->sync_offset; + pDCB->tinfo.goal.width = spi->bus_width; + } + splx(intflag); +#else TRM_DPRINTF(" XPT_SET_TRAN_SETTINGS \n"); - cts = &pccb->cts; update_type = 0; if ((cts->flags & CCB_TRANS_CURRENT_SETTINGS) != 0) update_type |= TRM_TRANS_GOAL; @@ -975,6 +1122,7 @@ trm_action(struct cam_sim *psim, union ccb *pccb) pDCB->tinfo.goal.width = cts->bus_width; } splx(intflag); +#endif pccb->ccb_h.status = CAM_REQ_CMP; xpt_done(pccb); break; @@ -2282,9 +2430,17 @@ trm_SetXferRate(PACB pACB,PSRB pSRB, PDCB pDCB) */ TRM_DPRINTF("trm_SetXferRate\n"); pccb = pSRB->pccb; + memset(&neg, 0, sizeof (neg)); +#ifdef CAM_NEW_TRAN_CODE + neg.xport_specific.spi.sync_period = pDCB->tinfo.goal.period; + neg.xport_specific.spi.sync_offset = pDCB->tinfo.goal.offset; + neg.xport_specific.spi.valid = + CTS_SPI_VALID_SYNC_RATE | CTS_SPI_VALID_SYNC_OFFSET; +#else neg.sync_period = pDCB->tinfo.goal.period; neg.sync_offset = pDCB->tinfo.goal.offset; neg.valid = CCB_TRANS_SYNC_RATE_VALID | CCB_TRANS_SYNC_OFFSET_VALID; +#endif xpt_setup_ccb(&neg.ccb_h, pccb->ccb_h.path, /* priority */1); xpt_async(AC_TRANSFER_NEG, pccb->ccb_h.path, &neg); if (!(pDCB->IdentifyMsg & 0x07)) { |
