From f19fcfb0e6b7b168730c36e2bcdc43e863d20d48 Mon Sep 17 00:00:00 2001 From: Peter Avalos Date: Sun, 23 Dec 2007 07:00:57 +0000 Subject: [PATCH] Fixes for CAM_NEW_TRAN_CODE. This commit is taken from a FreeBSD changeset, and is not intended to be comprehensive. Some drivers will still not compile/work with the CAM_NEW_TRAN_CODE option, but this opens the door for wider testing. Obtained-from: FreeBSD --- sys/bus/cam/scsi/scsi_low.c | 55 ++++++++++- sys/dev/disk/advansys/advansys.c | 135 ++++++++++++++++++++++++-- sys/dev/disk/advansys/advlib.c | 19 +++- sys/dev/disk/advansys/adwcam.c | 202 ++++++++++++++++++++++++++++++++++++++- sys/dev/disk/aha/aha.c | 78 ++++++++++++++- sys/dev/disk/ahb/ahb.c | 62 ++++++++++-- sys/dev/disk/aic/aic.c | 129 ++++++++++++++++++++++--- sys/dev/disk/amd/amd.c | 187 +++++++++++++++++++++++++++++++++--- sys/dev/disk/ata/atapi-cam.c | 23 ++++- sys/dev/disk/nata/atapi-cam.c | 23 ++++- sys/dev/disk/ncr/ncr.c | 184 +++++++++++++++++++++++++++++++++-- sys/dev/disk/sbp/sbp.c | 31 +++++- sys/dev/disk/trm/trm.c | 160 +++++++++++++++++++++++++++++-- sys/dev/raid/aac/aac_cam.c | 9 +- sys/dev/raid/amr/amr_cam.c | 36 ++++++- sys/dev/raid/asr/asr.c | 43 +++++++-- sys/dev/raid/ciss/ciss.c | 26 ++++- sys/dev/raid/dpt/dpt_scsi.c | 45 ++++++++- sys/dev/raid/iir/iir.c | 42 ++++++-- sys/dev/usbmisc/umass/umass.c | 10 +- 20 files changed, 1398 insertions(+), 101 deletions(-) diff --git a/sys/bus/cam/scsi/scsi_low.c b/sys/bus/cam/scsi/scsi_low.c index f187895200..baa6bb4bb1 100644 --- a/sys/bus/cam/scsi/scsi_low.c +++ b/sys/bus/cam/scsi/scsi_low.c @@ -1,6 +1,6 @@ /* * $FreeBSD: src/sys/cam/scsi/scsi_low.c,v 1.1.2.5 2003/08/09 06:18:30 non Exp $ - * $DragonFly: src/sys/bus/cam/scsi/scsi_low.c,v 1.25 2007/12/01 22:21:17 pavalos Exp $ + * $DragonFly: src/sys/bus/cam/scsi/scsi_low.c,v 1.26 2007/12/23 07:00:55 pavalos Exp $ * $NetBSD: scsi_low.c,v 1.24.10.8 2001/06/26 07:39:44 honda Exp $ */ @@ -523,6 +523,10 @@ scsi_low_scsi_action_cam(struct cam_sim *sim, union ccb *ccb) break; case XPT_SET_TRAN_SETTINGS: { +#ifdef CAM_NEW_TRAN_CODE + struct ccb_trans_settings_scsi *scsi; + struct ccb_trans_settings_spi *spi; +#endif struct ccb_trans_settings *cts; u_int val; @@ -541,6 +545,7 @@ scsi_low_scsi_action_cam(struct cam_sim *sim, union ccb *ccb) lun = 0; crit_enter(); +#ifndef CAM_NEW_TRAN_CODE if ((cts->valid & (CCB_TRANS_BUS_WIDTH_VALID | CCB_TRANS_SYNC_RATE_VALID | CCB_TRANS_SYNC_OFFSET_VALID)) != 0) @@ -590,6 +595,54 @@ scsi_low_scsi_action_cam(struct cam_sim *sim, union ccb *ccb) if ((slp->sl_show_result & SHOW_CALCF_RES) != 0) scsi_low_calcf_show(li); } +#else + scsi = &cts->proto_specific.scsi; + spi = &cts->xport_specific.spi; + if ((spi->valid & (CTS_SPI_VALID_BUS_WIDTH | + CTS_SPI_VALID_SYNC_RATE | + CTS_SPI_VALID_SYNC_OFFSET)) != 0) + { + if (spi->valid & CTS_SPI_VALID_BUS_WIDTH) { + val = spi->bus_width; + if (val < ti->ti_width) + ti->ti_width = val; + } + if (spi->valid & CTS_SPI_VALID_SYNC_RATE) { + val = spi->sync_period; + if (val == 0 || val > ti->ti_maxsynch.period) + ti->ti_maxsynch.period = val; + } + if (spi->valid & CTS_SPI_VALID_SYNC_OFFSET) { + val = spi->sync_offset; + if (val < ti->ti_maxsynch.offset) + ti->ti_maxsynch.offset = val; + } + ti->ti_flags_valid |= SCSI_LOW_TARG_FLAGS_QUIRKS_VALID; + scsi_low_calcf_target(ti); + } + + if ((spi->valid & CTS_SPI_FLAGS_DISC_ENB) != 0 || + (scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) != 0) { + + li = scsi_low_alloc_li(ti, lun, 1); + if (spi->valid & CTS_SPI_FLAGS_DISC_ENB) { + li->li_quirks |= SCSI_LOW_DISK_DISC; + } else { + li->li_quirks &= ~SCSI_LOW_DISK_DISC; + } + + if (scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) { + li->li_quirks |= SCSI_LOW_DISK_QTAG; + } else { + li->li_quirks &= ~SCSI_LOW_DISK_QTAG; + } + li->li_flags_valid |= SCSI_LOW_LUN_FLAGS_QUIRKS_VALID; + scsi_low_calcf_target(ti); + scsi_low_calcf_lun(li); + if ((slp->sl_show_result & SHOW_CALCF_RES) != 0) + scsi_low_calcf_show(li); + } +#endif crit_exit(); ccb->ccb_h.status = CAM_REQ_CMP; diff --git a/sys/dev/disk/advansys/advansys.c b/sys/dev/disk/advansys/advansys.c index 4f638e3f41..abefe0d205 100644 --- a/sys/dev/disk/advansys/advansys.c +++ b/sys/dev/disk/advansys/advansys.c @@ -33,7 +33,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/advansys/advansys.c,v 1.14.2.4 2002/01/06 21:21:42 dwmalone Exp $ - * $DragonFly: src/sys/dev/disk/advansys/advansys.c,v 1.11 2006/12/22 23:26:15 swildner Exp $ + * $DragonFly: src/sys/dev/disk/advansys/advansys.c,v 1.12 2007/12/23 07:00:55 pavalos Exp $ */ /* * Ported from: @@ -281,8 +281,19 @@ adv_action(struct cam_sim *sim, union ccb *ccb) ccb->ccb_h.status = CAM_REQ_INVALID; xpt_done(ccb); break; +#ifdef CAM_NEW_TRAN_CODE +#define IS_CURRENT_SETTINGS(c) (c->type == CTS_TYPE_CURRENT_SETTINGS) +#define IS_USER_SETTINGS(c) (c->type == CTS_TYPE_USER_SETTINGS) +#else +#define IS_CURRENT_SETTINGS(c) (c->flags & CCB_TRANS_CURRENT_SETTINGS) +#define IS_USER_SETTINGS(c) (c->flags & CCB_TRANS_USER_SETTINGS) +#endif case XPT_SET_TRAN_SETTINGS: { +#ifdef CAM_NEW_TRAN_CODE + struct ccb_trans_settings_scsi *scsi; + struct ccb_trans_settings_spi *spi; +#endif struct ccb_trans_settings *cts; target_bit_vector targ_mask; struct adv_transinfo *tconf; @@ -296,12 +307,10 @@ adv_action(struct cam_sim *sim, union ccb *ccb) * The user must specify which type of settings he wishes * to change. */ - if (((cts->flags & CCB_TRANS_CURRENT_SETTINGS) != 0) - && ((cts->flags & CCB_TRANS_USER_SETTINGS) == 0)) { + if (IS_CURRENT_SETTINGS(cts) && !IS_USER_SETTINGS(cts)) { tconf = &adv->tinfo[cts->ccb_h.target_id].current; update_type |= ADV_TRANS_GOAL; - } else if (((cts->flags & CCB_TRANS_USER_SETTINGS) != 0) - && ((cts->flags & CCB_TRANS_CURRENT_SETTINGS) == 0)) { + } else if (IS_USER_SETTINGS(cts) && !IS_CURRENT_SETTINGS(cts)) { tconf = &adv->tinfo[cts->ccb_h.target_id].user; update_type |= ADV_TRANS_USER; } else { @@ -310,6 +319,73 @@ adv_action(struct cam_sim *sim, union ccb *ccb) } crit_enter(); +#ifdef CAM_NEW_TRAN_CODE + scsi = &cts->proto_specific.scsi; + spi = &cts->xport_specific.spi; + if ((update_type & ADV_TRANS_GOAL) != 0) { + if ((spi->valid & CTS_SPI_VALID_DISC) != 0) { + if ((spi->flags & CTS_SPI_FLAGS_DISC_ENB) != 0) + adv->disc_enable |= targ_mask; + else + adv->disc_enable &= ~targ_mask; + adv_write_lram_8(adv, ADVV_DISC_ENABLE_B, + adv->disc_enable); + } + + if ((scsi->valid & CTS_SCSI_VALID_TQ) != 0) { + if ((scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) != 0) + adv->cmd_qng_enabled |= targ_mask; + else + adv->cmd_qng_enabled &= ~targ_mask; + } + } + + if ((update_type & ADV_TRANS_USER) != 0) { + if ((spi->valid & CTS_SPI_VALID_DISC) != 0) { + if ((spi->flags & CTS_SPI_VALID_DISC) != 0) + adv->user_disc_enable |= targ_mask; + else + adv->user_disc_enable &= ~targ_mask; + } + + if ((scsi->valid & CTS_SCSI_VALID_TQ) != 0) { + if ((scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) != 0) + adv->user_cmd_qng_enabled |= targ_mask; + else + adv->user_cmd_qng_enabled &= ~targ_mask; + } + } + + /* + * If the user specifies either the sync rate, or offset, + * but not both, the unspecified parameter defaults to its + * current value in transfer negotiations. + */ + if (((spi->valid & CTS_SPI_VALID_SYNC_RATE) != 0) + || ((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) != 0)) { + /* + * If the user provided a sync rate but no offset, + * use the current offset. + */ + if ((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) == 0) + spi->sync_offset = tconf->offset; + + /* + * If the user provided an offset but no sync rate, + * use the current sync rate. + */ + if ((spi->valid & CTS_SPI_VALID_SYNC_RATE) == 0) + spi->sync_period = tconf->period; + + adv_period_offset_to_sdtr(adv, &spi->sync_period, + &spi->sync_offset, + cts->ccb_h.target_id); + + adv_set_syncrate(adv, /*struct cam_path */NULL, + cts->ccb_h.target_id, spi->sync_period, + spi->sync_offset, update_type); + } +#else if ((update_type & ADV_TRANS_GOAL) != 0) { if ((cts->valid & CCB_TRANS_DISC_VALID) != 0) { if ((cts->flags & CCB_TRANS_DISC_ENB) != 0) @@ -373,6 +449,7 @@ adv_action(struct cam_sim *sim, union ccb *ccb) cts->ccb_h.target_id, cts->sync_period, cts->sync_offset, update_type); } +#endif crit_exit(); ccb->ccb_h.status = CAM_REQ_CMP; @@ -382,6 +459,10 @@ adv_action(struct cam_sim *sim, union ccb *ccb) case XPT_GET_TRAN_SETTINGS: /* Get default/user set transfer settings for the target */ { +#ifdef CAM_NEW_TRAN_CODE + struct ccb_trans_settings_scsi *scsi; + struct ccb_trans_settings_spi *spi; +#endif struct ccb_trans_settings *cts; struct adv_transinfo *tconf; target_bit_vector target_mask; @@ -389,8 +470,43 @@ adv_action(struct cam_sim *sim, union ccb *ccb) cts = &ccb->cts; target_mask = ADV_TID_TO_TARGET_MASK(cts->ccb_h.target_id); - cts->flags &= ~(CCB_TRANS_DISC_ENB|CCB_TRANS_TAG_ENB); +#ifdef CAM_NEW_TRAN_CODE + scsi = &cts->proto_specific.scsi; + 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; + + crit_enter(); + if (cts->type == CTS_TYPE_CURRENT_SETTINGS) { + tconf = &adv->tinfo[cts->ccb_h.target_id].current; + if ((adv->disc_enable & target_mask) != 0) + spi->flags |= CTS_SPI_FLAGS_DISC_ENB; + if ((adv->cmd_qng_enabled & target_mask) != 0) + scsi->flags |= CTS_SCSI_FLAGS_TAG_ENB; + } else { + tconf = &adv->tinfo[cts->ccb_h.target_id].user; + if ((adv->user_disc_enable & target_mask) != 0) + spi->flags |= CTS_SPI_FLAGS_DISC_ENB; + if ((adv->user_cmd_qng_enabled & target_mask) != 0) + scsi->flags |= CTS_SCSI_FLAGS_TAG_ENB; + } + spi->sync_period = tconf->period; + spi->sync_offset = tconf->offset; + crit_exit(); + 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 + cts->flags &= ~(CCB_TRANS_DISC_ENB|CCB_TRANS_TAG_ENB); crit_enter(); if ((cts->flags & CCB_TRANS_CURRENT_SETTINGS) != 0) { tconf = &adv->tinfo[cts->ccb_h.target_id].current; @@ -416,6 +532,7 @@ adv_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); break; @@ -481,6 +598,12 @@ adv_action(struct cam_sim *sim, union ccb *ccb) strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->ccb_h.status = CAM_REQ_CMP; +#ifdef CAM_NEW_TRAN_CODE + cpi->transport = XPORT_SPI; + cpi->transport_version = 2; + cpi->protocol = PROTO_SCSI; + cpi->protocol_version = SCSI_REV_2; +#endif xpt_done(ccb); break; } diff --git a/sys/dev/disk/advansys/advlib.c b/sys/dev/disk/advansys/advlib.c index 7b5ddecb62..af64b4f526 100644 --- a/sys/dev/disk/advansys/advlib.c +++ b/sys/dev/disk/advansys/advlib.c @@ -29,7 +29,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/advansys/advlib.c,v 1.15.2.1 2000/04/14 13:32:49 nyan Exp $ - * $DragonFly: src/sys/dev/disk/advansys/advlib.c,v 1.8 2006/12/22 23:26:15 swildner Exp $ + * $DragonFly: src/sys/dev/disk/advansys/advlib.c,v 1.9 2007/12/23 07:00:55 pavalos Exp $ */ /* * Ported from: @@ -1128,11 +1128,26 @@ adv_set_syncrate(struct adv_softc *adv, struct cam_path *path, * new transfer parameters. */ struct ccb_trans_settings neg; - + memset(&neg, 0, sizeof (neg)); +#ifdef CAM_NEW_TRAN_CODE + struct ccb_trans_settings_spi *spi = + &neg.xport_specific.spi; + + neg.protocol = PROTO_SCSI; + neg.protocol_version = SCSI_REV_2; + neg.transport = XPORT_SPI; + neg.transport_version = 2; + + spi->sync_offset = offset; + spi->sync_period = period; + spi->valid |= CTS_SPI_VALID_SYNC_OFFSET; + spi->valid |= CTS_SPI_VALID_SYNC_RATE; +#else neg.sync_period = period; neg.sync_offset = offset; neg.valid = CCB_TRANS_SYNC_RATE_VALID | CCB_TRANS_SYNC_OFFSET_VALID; +#endif xpt_setup_ccb(&neg.ccb_h, path, /*priority*/1); xpt_async(AC_TRANSFER_NEG, path, &neg); } diff --git a/sys/dev/disk/advansys/adwcam.c b/sys/dev/disk/advansys/adwcam.c index 1ab94d710f..4f8ff3a531 100644 --- a/sys/dev/disk/advansys/adwcam.c +++ b/sys/dev/disk/advansys/adwcam.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/advansys/adwcam.c,v 1.7.2.2 2001/03/05 13:08:55 obrien Exp $ - * $DragonFly: src/sys/dev/disk/advansys/adwcam.c,v 1.16 2007/05/13 18:33:57 swildner Exp $ + * $DragonFly: src/sys/dev/disk/advansys/adwcam.c,v 1.17 2007/12/23 07:00:56 pavalos Exp $ */ /* * Ported from: @@ -512,6 +512,10 @@ adw_action(struct cam_sim *sim, union ccb *ccb) break; case XPT_SET_TRAN_SETTINGS: { +#ifdef CAM_NEW_TRAN_CODE + struct ccb_trans_settings_scsi *scsi; + struct ccb_trans_settings_spi *spi; +#endif struct ccb_trans_settings *cts; u_int target_mask; @@ -519,6 +523,119 @@ adw_action(struct cam_sim *sim, union ccb *ccb) target_mask = 0x01 << ccb->ccb_h.target_id; crit_enter(); +#ifdef CAM_NEW_TRAN_CODE + scsi = &cts->proto_specific.scsi; + spi = &cts->xport_specific.spi; + if (cts->type == CTS_TYPE_CURRENT_SETTINGS) { + u_int sdtrdone; + + sdtrdone = adw_lram_read_16(adw, ADW_MC_SDTR_DONE); + if ((spi->valid & CTS_SPI_VALID_DISC) != 0) { + u_int discenb; + + discenb = + adw_lram_read_16(adw, ADW_MC_DISC_ENABLE); + + if ((spi->flags & CTS_SPI_FLAGS_DISC_ENB) != 0) + discenb |= target_mask; + else + discenb &= ~target_mask; + + adw_lram_write_16(adw, ADW_MC_DISC_ENABLE, + discenb); + } + + if ((scsi->valid & CTS_SCSI_VALID_TQ) != 0) { + + if ((scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) != 0) + adw->tagenb |= target_mask; + else + adw->tagenb &= ~target_mask; + } + + if ((spi->valid & CTS_SPI_VALID_BUS_WIDTH) != 0) { + u_int wdtrenb_orig; + u_int wdtrenb; + u_int wdtrdone; + + wdtrenb_orig = + adw_lram_read_16(adw, ADW_MC_WDTR_ABLE); + wdtrenb = wdtrenb_orig; + wdtrdone = adw_lram_read_16(adw, + ADW_MC_WDTR_DONE); + switch (spi->bus_width) { + case MSG_EXT_WDTR_BUS_32_BIT: + case MSG_EXT_WDTR_BUS_16_BIT: + wdtrenb |= target_mask; + break; + case MSG_EXT_WDTR_BUS_8_BIT: + default: + wdtrenb &= ~target_mask; + break; + } + if (wdtrenb != wdtrenb_orig) { + adw_lram_write_16(adw, + ADW_MC_WDTR_ABLE, + wdtrenb); + wdtrdone &= ~target_mask; + adw_lram_write_16(adw, + ADW_MC_WDTR_DONE, + wdtrdone); + /* Wide negotiation forces async */ + sdtrdone &= ~target_mask; + adw_lram_write_16(adw, + ADW_MC_SDTR_DONE, + sdtrdone); + } + } + + if (((spi->valid & CTS_SPI_VALID_SYNC_RATE) != 0) + || ((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) != 0)) { + u_int sdtr_orig; + u_int sdtr; + u_int sdtrable_orig; + u_int sdtrable; + + sdtr = adw_get_chip_sdtr(adw, + ccb->ccb_h.target_id); + sdtr_orig = sdtr; + sdtrable = adw_lram_read_16(adw, + ADW_MC_SDTR_ABLE); + sdtrable_orig = sdtrable; + + if ((spi->valid + & CTS_SPI_VALID_SYNC_RATE) != 0) { + + sdtr = + adw_find_sdtr(adw, + spi->sync_period); + } + + if ((spi->valid + & CTS_SPI_VALID_SYNC_OFFSET) != 0) { + if (spi->sync_offset == 0) + sdtr = ADW_MC_SDTR_ASYNC; + } + + if (sdtr == ADW_MC_SDTR_ASYNC) + sdtrable &= ~target_mask; + else + sdtrable |= target_mask; + if (sdtr != sdtr_orig + || sdtrable != sdtrable_orig) { + adw_set_chip_sdtr(adw, + ccb->ccb_h.target_id, + sdtr); + sdtrdone &= ~target_mask; + adw_lram_write_16(adw, ADW_MC_SDTR_ABLE, + sdtrable); + adw_lram_write_16(adw, ADW_MC_SDTR_DONE, + sdtrdone); + + } + } + } +#else if ((cts->flags & CCB_TRANS_CURRENT_SETTINGS) != 0) { u_int sdtrdone; @@ -628,6 +745,7 @@ adw_action(struct cam_sim *sim, union ccb *ccb) } } } +#endif crit_exit(); ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); @@ -636,12 +754,85 @@ adw_action(struct cam_sim *sim, union ccb *ccb) case XPT_GET_TRAN_SETTINGS: /* Get default/user set transfer settings for the target */ { +#ifdef CAM_NEW_TRAN_CODE + struct ccb_trans_settings_scsi *scsi; + struct ccb_trans_settings_spi *spi; +#endif struct ccb_trans_settings *cts; u_int target_mask; cts = &ccb->cts; target_mask = 0x01 << ccb->ccb_h.target_id; - if ((cts->flags & CCB_TRANS_USER_SETTINGS) != 0) { +#ifdef CAM_NEW_TRAN_CODE + cts->protocol = PROTO_SCSI; + cts->protocol_version = SCSI_REV_2; + cts->transport = XPORT_SPI; + cts->transport_version = 2; + + scsi = &cts->proto_specific.scsi; + spi = &cts->xport_specific.spi; + if (cts->type == CTS_TYPE_CURRENT_SETTINGS) { + u_int mc_sdtr; + + spi->flags = 0; + if ((adw->user_discenb & target_mask) != 0) + spi->flags |= CTS_SPI_FLAGS_DISC_ENB; + + if ((adw->user_tagenb & target_mask) != 0) + scsi->flags |= CTS_SCSI_FLAGS_TAG_ENB; + + if ((adw->user_wdtr & target_mask) != 0) + spi->bus_width = MSG_EXT_WDTR_BUS_16_BIT; + else + spi->bus_width = MSG_EXT_WDTR_BUS_8_BIT; + + mc_sdtr = adw_get_user_sdtr(adw, ccb->ccb_h.target_id); + spi->sync_period = adw_find_period(adw, mc_sdtr); + if (spi->sync_period != 0) + spi->sync_offset = 15; /* XXX ??? */ + else + spi->sync_offset = 0; + + + } else { + u_int targ_tinfo; + + spi->flags = 0; + if ((adw_lram_read_16(adw, ADW_MC_DISC_ENABLE) + & target_mask) != 0) + spi->flags |= CTS_SPI_FLAGS_DISC_ENB; + + if ((adw->tagenb & target_mask) != 0) + scsi->flags |= CTS_SCSI_FLAGS_TAG_ENB; + + targ_tinfo = + adw_lram_read_16(adw, + ADW_MC_DEVICE_HSHK_CFG_TABLE + + (2 * ccb->ccb_h.target_id)); + + if ((targ_tinfo & ADW_HSHK_CFG_WIDE_XFR) != 0) + spi->bus_width = MSG_EXT_WDTR_BUS_16_BIT; + else + spi->bus_width = MSG_EXT_WDTR_BUS_8_BIT; + + spi->sync_period = + adw_hshk_cfg_period_factor(targ_tinfo); + + spi->sync_offset = targ_tinfo & ADW_HSHK_CFG_OFFSET; + if (spi->sync_period == 0) + spi->sync_offset = 0; + + if (spi->sync_offset == 0) + spi->sync_period = 0; + } + + 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 + if ((cts->flags & CCB_TRANS_USER_SETTINGS) != 0) { u_int mc_sdtr; cts->flags = 0; @@ -705,6 +896,7 @@ adw_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); break; @@ -778,6 +970,12 @@ adw_action(struct cam_sim *sim, union ccb *ccb) strncpy(cpi->hba_vid, "AdvanSys", 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; diff --git a/sys/dev/disk/aha/aha.c b/sys/dev/disk/aha/aha.c index 8814b4942a..dd6f500728 100644 --- a/sys/dev/disk/aha/aha.c +++ b/sys/dev/disk/aha/aha.c @@ -56,7 +56,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/aha/aha.c,v 1.34.2.1 2000/08/02 22:24:39 peter Exp $ - * $DragonFly: src/sys/dev/disk/aha/aha.c,v 1.17 2007/05/13 18:33:57 swildner Exp $ + * $DragonFly: src/sys/dev/disk/aha/aha.c,v 1.18 2007/12/23 07:00:56 pavalos Exp $ */ #include @@ -979,11 +979,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) @@ -1008,6 +1041,7 @@ ahaaction(struct cam_sim *sim, union ccb *ccb) } else { ahafetchtransinfo(aha, cts); } +#endif ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); @@ -1071,6 +1105,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; @@ -1760,6 +1800,9 @@ ahafetchtransinfo(struct aha_softc *aha, struct ccb_trans_settings* cts) int error; u_int8_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); @@ -1782,6 +1825,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 @@ -1804,6 +1871,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); } diff --git a/sys/dev/disk/ahb/ahb.c b/sys/dev/disk/ahb/ahb.c index b0c20e773e..94fd2069b0 100644 --- a/sys/dev/disk/ahb/ahb.c +++ b/sys/dev/disk/ahb/ahb.c @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ahb/ahb.c,v 1.18.2.3 2001/03/05 13:08:55 obrien Exp $ - * $DragonFly: src/sys/dev/disk/ahb/ahb.c,v 1.16 2007/12/02 03:54:16 pavalos Exp $ + * $DragonFly: src/sys/dev/disk/ahb/ahb.c,v 1.17 2007/12/23 07:00:56 pavalos Exp $ */ #include @@ -701,12 +701,24 @@ ahbprocesserror(struct ahb_softc *ahb, struct ecb *ecb, union ccb *ccb) case HS_TAG_MSG_REJECTED: { struct ccb_trans_settings neg; +#ifdef CAM_NEW_TRAN_CODE + struct ccb_trans_settings_scsi *scsi = &neg.proto_specific.scsi; +#endif xpt_print_path(ccb->ccb_h.path); kprintf("refuses tagged commands. Performing " "non-tagged I/O\n"); + 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; + scsi->flags = CTS_SCSI_VALID_TQ; +#else neg.flags = 0; neg.valid = CCB_TRANS_TQ_VALID; +#endif xpt_setup_ccb(&neg.ccb_h, ccb->ccb_h.path, /*priority*/1); xpt_async(AC_TRANSFER_NEG, ccb->ccb_h.path, &neg); ahb->tags_permitted &= ~(0x01 << ccb->ccb_h.target_id); @@ -1099,11 +1111,42 @@ ahbaction(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; - - cts = &ccb->cts; - target_mask = 0x01 << ccb->ccb_h.target_id; + 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; + + if (cts->type == CTS_TYPE_USER_SETTINGS) { + 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; + if ((ahb->disc_permitted & target_mask) != 0) + spi->flags |= CTS_SPI_FLAGS_DISC_ENB; + if ((ahb->tags_permitted & target_mask) != 0) + scsi->flags |= CTS_SCSI_FLAGS_TAG_ENB; + spi->bus_width = MSG_EXT_WDTR_BUS_8_BIT; + spi->sync_period = 25; /* 10MHz */ + + 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; + ccb->ccb_h.status = CAM_REQ_CMP; + } else { + ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; + } +#else if ((cts->flags & CCB_TRANS_USER_SETTINGS) != 0) { cts->flags = 0; if ((ahb->disc_permitted & target_mask) != 0) @@ -1125,6 +1168,7 @@ ahbaction(struct cam_sim *sim, union ccb *ccb) } else { ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; } +#endif xpt_done(ccb); break; } @@ -1202,6 +1246,12 @@ ahbaction(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; diff --git a/sys/dev/disk/aic/aic.c b/sys/dev/disk/aic/aic.c index 8428541ec2..08b79e4ddc 100644 --- a/sys/dev/disk/aic/aic.c +++ b/sys/dev/disk/aic/aic.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/aic/aic.c,v 1.8 2000/01/14 23:42:35 imp Exp $ - * $DragonFly: src/sys/dev/disk/aic/aic.c,v 1.9 2006/12/22 23:26:15 swildner Exp $ + * $DragonFly: src/sys/dev/disk/aic/aic.c,v 1.10 2007/12/23 07:00:56 pavalos Exp $ */ #include @@ -173,14 +173,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; crit_enter(); + 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; + + crit_exit(); +#else + crit_enter(); if ((cts->valid & CCB_TRANS_DISC_VALID) != 0 && (aic->flags & AIC_DISC_ENABLE) != 0) { if ((cts->flags & CCB_TRANS_DISC_ENB) != 0) @@ -209,20 +251,51 @@ aic_action(struct cam_sim *sim, union ccb *ccb) } crit_exit(); +#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; crit_enter(); + 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; + } + crit_exit() + + 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 + crit_enter(); cts->flags &= ~(CCB_TRANS_DISC_ENB|CCB_TRANS_TAG_ENB); if ((ti->flags & TINFO_DISC_ENB) != 0) cts->flags |= CCB_TRANS_DISC_ENB; @@ -245,6 +318,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); @@ -297,6 +371,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; @@ -612,6 +692,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])) { @@ -697,10 +780,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); @@ -736,10 +831,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); diff --git a/sys/dev/disk/amd/amd.c b/sys/dev/disk/amd/amd.c index ebfd3958d1..1fe00e418f 100644 --- a/sys/dev/disk/amd/amd.c +++ b/sys/dev/disk/amd/amd.c @@ -31,7 +31,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ********************************************************************* * $FreeBSD: src/sys/pci/amd.c,v 1.3.2.2 2001/06/02 04:32:50 nyan Exp $ - * $DragonFly: src/sys/dev/disk/amd/amd.c,v 1.13 2007/05/13 18:33:57 swildner Exp $ + * $DragonFly: src/sys/dev/disk/amd/amd.c,v 1.14 2007/12/23 07:00:56 pavalos Exp $ */ /* @@ -476,6 +476,12 @@ amd_action(struct cam_sim * psim, union ccb * pccb) strncpy(cpi->hba_vid, "TRM-AMD", 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); break; @@ -508,15 +514,63 @@ amd_action(struct cam_sim * psim, union ccb * pccb) case XPT_TERM_IO: pccb->ccb_h.status = CAM_REQ_INVALID; xpt_done(pccb); + break; case XPT_GET_TRAN_SETTINGS: { - struct ccb_trans_settings *cts; - struct amd_target_info *targ_info; + struct ccb_trans_settings *cts = &pccb->cts; + struct amd_target_info *targ_info = &amd->tinfo[target_id]; struct amd_transinfo *tinfo; +#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; - cts = &pccb->cts; crit_enter(); - targ_info = &amd->tinfo[target_id]; + if (cts->type == CTS_TYPE_CURRENT_SETTINGS) { + /* current transfer settings */ + if (targ_info->disc_tag & AMD_CUR_DISCENB) { + spi->flags = CTS_SPI_FLAGS_DISC_ENB; + } else { + spi->flags = 0; + } + if (targ_info->disc_tag & AMD_CUR_TAGENB) { + scsi->flags = CTS_SCSI_FLAGS_TAG_ENB; + } else { + scsi->flags = 0; + } + tinfo = &targ_info->current; + } else { + /* default(user) transfer settings */ + if (targ_info->disc_tag & AMD_USR_DISCENB) { + spi->flags = CTS_SPI_FLAGS_DISC_ENB; + } else { + spi->flags = 0; + } + if (targ_info->disc_tag & AMD_USR_TAGENB) { + scsi->flags = CTS_SCSI_FLAGS_TAG_ENB; + } else { + scsi->flags = 0; + } + tinfo = &targ_info->user; + } + spi->sync_period = tinfo->period; + spi->sync_offset = tinfo->offset; + crit_exit(); + + 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 + crit_enter(); if ((cts->flags & CCB_TRANS_CURRENT_SETTINGS) != 0) { /* current transfer settings */ if (targ_info->disc_tag & AMD_CUR_DISCENB) { @@ -545,27 +599,40 @@ amd_action(struct cam_sim * psim, union ccb * pccb) cts->sync_offset = tinfo->offset; cts->bus_width = MSG_EXT_WDTR_BUS_8_BIT; crit_exit(); + cts->valid = CCB_TRANS_SYNC_RATE_VALID | CCB_TRANS_SYNC_OFFSET_VALID | CCB_TRANS_BUS_WIDTH_VALID | CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID; +#endif pccb->ccb_h.status = CAM_REQ_CMP; xpt_done(pccb); break; } +#ifdef CAM_NEW_TRAN_CODE +#define IS_CURRENT_SETTINGS(c) (c->type == CTS_TYPE_CURRENT_SETTINGS) +#define IS_USER_SETTINGS(c) (c->type == CTS_TYPE_USER_SETTINGS) +#else +#define IS_CURRENT_SETTINGS(c) (c->flags & CCB_TRANS_CURRENT_SETTINGS) +#define IS_USER_SETTINGS(c) (c->flags & CCB_TRANS_USER_SETTINGS) +#endif case XPT_SET_TRAN_SETTINGS: { - struct ccb_trans_settings *cts; + struct ccb_trans_settings *cts = &pccb->cts; struct amd_target_info *targ_info; - u_int update_type; + u_int update_type = 0; int last_entry; - cts = &pccb->cts; - update_type = 0; - if ((cts->flags & CCB_TRANS_CURRENT_SETTINGS) != 0) { +#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; +#endif + if (IS_CURRENT_SETTINGS(cts)) { update_type |= AMD_TRANS_GOAL; - } else if ((cts->flags & CCB_TRANS_USER_SETTINGS) != 0) { + } else if (IS_USER_SETTINGS(cts)) { update_type |= AMD_TRANS_USER; } if (update_type == 0 @@ -574,6 +641,82 @@ amd_action(struct cam_sim * psim, union ccb * pccb) xpt_done(pccb); } +#ifdef CAM_NEW_TRAN_CODE + crit_enter(); + targ_info = &amd->tinfo[target_id]; + + if ((spi->valid & CTS_SPI_VALID_DISC) != 0) { + if (update_type & AMD_TRANS_GOAL) { + if ((spi->flags & CTS_SPI_FLAGS_DISC_ENB) + != 0) { + targ_info->disc_tag |= AMD_CUR_DISCENB; + } else { + targ_info->disc_tag &= ~AMD_CUR_DISCENB; + } + } + if (update_type & AMD_TRANS_USER) { + if ((spi->flags & CTS_SPI_FLAGS_DISC_ENB) + != 0) { + targ_info->disc_tag |= AMD_USR_DISCENB; + } else { + targ_info->disc_tag &= ~AMD_USR_DISCENB; + } + } + } + if ((scsi->valid & CTS_SCSI_VALID_TQ) != 0) { + if (update_type & AMD_TRANS_GOAL) { + if ((scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) + != 0) { + targ_info->disc_tag |= AMD_CUR_TAGENB; + } else { + targ_info->disc_tag &= ~AMD_CUR_TAGENB; + } + } + if (update_type & AMD_TRANS_USER) { + if ((scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) + != 0) { + targ_info->disc_tag |= AMD_USR_TAGENB; + } else { + targ_info->disc_tag &= ~AMD_USR_TAGENB; + } + } + } + + if ((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) == 0) { + if (update_type & AMD_TRANS_GOAL) + spi->sync_offset = targ_info->goal.offset; + else + spi->sync_offset = targ_info->user.offset; + } + + if (spi->sync_offset > AMD_MAX_SYNC_OFFSET) + spi->sync_offset = AMD_MAX_SYNC_OFFSET; + + if ((spi->valid & CTS_SPI_VALID_SYNC_RATE) == 0) { + if (update_type & AMD_TRANS_GOAL) + spi->sync_period = targ_info->goal.period; + else + spi->sync_period = targ_info->user.period; + } + + last_entry = sizeof(tinfo_sync_period) - 1; + if ((spi->sync_period != 0) + && (spi->sync_period < tinfo_sync_period[0])) + spi->sync_period = tinfo_sync_period[0]; + if (spi->sync_period > tinfo_sync_period[last_entry]) + spi->sync_period = 0; + if (spi->sync_offset == 0) + spi->sync_period = 0; + + if ((update_type & AMD_TRANS_USER) != 0) { + targ_info->user.period = spi->sync_period; + targ_info->user.offset = spi->sync_offset; + } + if ((update_type & AMD_TRANS_GOAL) != 0) { + targ_info->goal.period = spi->sync_period; + targ_info->goal.offset = spi->sync_offset; + } +#else crit_enter(); targ_info = &amd->tinfo[target_id]; @@ -644,6 +787,7 @@ amd_action(struct cam_sim * psim, union ccb * pccb) targ_info->goal.period = cts->sync_period; targ_info->goal.offset = cts->sync_offset; } +#endif crit_exit(); pccb->ccb_h.status = CAM_REQ_CMP; xpt_done(pccb); @@ -792,12 +936,23 @@ amdsetsync(struct amd_softc *amd, u_int target, u_int clockrate, cam_sim_path(amd->psim), target, CAM_LUN_WILDCARD) == CAM_REQ_CMP) { struct ccb_trans_settings neg; - +#ifdef CAM_NEW_TRAN_CODE + struct ccb_trans_settings_spi *spi = + &neg.xport_specific.spi; +#endif xpt_setup_ccb(&neg.ccb_h, path, /*priority*/1); + memset(&neg, 0, sizeof (neg)); +#ifdef CAM_NEW_TRAN_CODE + spi->sync_period = period; + spi->sync_offset = offset; + spi->valid = CTS_SPI_VALID_SYNC_RATE + | CTS_SPI_VALID_SYNC_OFFSET; +#else neg.sync_period = period; neg.sync_offset = offset; neg.valid = CCB_TRANS_SYNC_RATE_VALID | CCB_TRANS_SYNC_OFFSET_VALID; +#endif xpt_async(AC_TRANSFER_NEG, path, &neg); xpt_free_path(path); } @@ -1454,13 +1609,21 @@ amdhandlemsgreject(struct amd_softc *amd) } else if ((srb != NULL) && (srb->pccb->ccb_h.flags & CAM_TAG_ACTION_VALID) != 0) { struct ccb_trans_settings neg; +#ifdef CAM_NEW_TRAN_CODE + struct ccb_trans_settings_scsi *scsi = &neg.proto_specific.scsi; +#endif kprintf("amd%d:%d: refuses tagged commands. Performing " "non-tagged I/O\n", amd->unit, amd->cur_target); amdsettags(amd, amd->cur_target, FALSE); + memset(&neg, 0, sizeof (neg)); +#ifdef CAM_NEW_TRAN_CODE + scsi->valid = CTS_SCSI_VALID_TQ; +#else neg.flags = 0; neg.valid = CCB_TRANS_TQ_VALID; +#endif xpt_setup_ccb(&neg.ccb_h, srb->pccb->ccb_h.path, /*priority*/1); xpt_async(AC_TRANSFER_NEG, srb->pccb->ccb_h.path, &neg); diff --git a/sys/dev/disk/ata/atapi-cam.c b/sys/dev/disk/ata/atapi-cam.c index a9987d236a..a196eb1aea 100644 --- a/sys/dev/disk/ata/atapi-cam.c +++ b/sys/dev/disk/ata/atapi-cam.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ata/atapi-cam.c,v 1.10.2.3 2003/05/21 09:24:55 thomas Exp $ - * $DragonFly: src/sys/dev/disk/ata/atapi-cam.c,v 1.12 2007/05/01 00:05:17 dillon Exp $ + * $DragonFly: src/sys/dev/disk/ata/atapi-cam.c,v 1.13 2007/12/23 07:00:56 pavalos Exp $ */ #include @@ -251,6 +251,12 @@ atapi_action(struct cam_sim *sim, union ccb *ccb) cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; +#ifdef CAM_NEW_TRAN_CODE + cpi->transport = XPORT_ATA; + cpi->transport_version = 2; + cpi->protocol = PROTO_SCSI; + cpi->protocol_version = SCSI_REV_2; +#endif if (softc->ata_ch && ccb_h->target_id != CAM_TARGET_WILDCARD) { switch (softc->ata_ch->device[ccb_h->target_id].mode) { case ATA_PIO1: @@ -316,16 +322,25 @@ atapi_action(struct cam_sim *sim, union ccb *ccb) case XPT_GET_TRAN_SETTINGS: { struct ccb_trans_settings *cts = &ccb->cts; - +#ifdef CAM_NEW_TRAN_CODE + cts->protocol = PROTO_SCSI; + cts->protocol_version = SCSI_REV_2; + cts->transport = XPORT_ATA; + cts->transport_version = XPORT_VERSION_UNSPECIFIED; + cts->proto_specific.valid = 0; + cts->xport_specific.valid = 0; + /* nothing more to do */ +#else /* - * XXX The default CAM transport code is very scsi specific and + * The default CAM transport code is very SCSI-specific and * doesn't understand IDE speeds very well. Be silent about it * here and let it default to what is set in XPT_PATH_INQ */ - CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_SUBTRACE, ("GET_TRAN_SETTINGS\n")); cts->valid = (CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID); cts->flags &= ~(CCB_TRANS_DISC_ENB | CCB_TRANS_TAG_ENB); +#endif ccb->ccb_h.status = CAM_REQ_CMP; + CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_SUBTRACE, ("GET_TRAN_SETTINGS\n")); xpt_done(ccb); return; } diff --git a/sys/dev/disk/nata/atapi-cam.c b/sys/dev/disk/nata/atapi-cam.c index f1a7ee3caf..5197283a9f 100644 --- a/sys/dev/disk/nata/atapi-cam.c +++ b/sys/dev/disk/nata/atapi-cam.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ata/atapi-cam.c,v 1.44 2006/03/31 08:09:05 sos Exp $ - * $DragonFly: src/sys/dev/disk/nata/atapi-cam.c,v 1.7 2007/07/23 19:24:11 dillon Exp $ + * $DragonFly: src/sys/dev/disk/nata/atapi-cam.c,v 1.8 2007/12/23 07:00:56 pavalos Exp $ */ #include "opt_ata.h" @@ -359,6 +359,12 @@ atapi_action(struct cam_sim *sim, union ccb *ccb) cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 3300; +#ifdef CAM_NEW_TRAN_CODE + cpi->transport = XPORT_ATA; + cpi->transport_version = 2; + cpi->protocol = PROTO_SCSI; + cpi->protocol_version = SCSI_REV_2; +#endif if (softc->ata_ch && tid != CAM_TARGET_WILDCARD) { spin_lock_wr(&softc->state_lock); @@ -432,16 +438,25 @@ atapi_action(struct cam_sim *sim, union ccb *ccb) case XPT_GET_TRAN_SETTINGS: { struct ccb_trans_settings *cts = &ccb->cts; - +#ifdef CAM_NEW_TRAN_CODE + cts->protocol = PROTO_SCSI; + cts->protocol_version = SCSI_REV_2; + cts->transport = XPORT_ATA; + cts->transport_version = XPORT_VERSION_UNSPECIFIED; + cts->proto_specific.valid = 0; + cts->xport_specific.valid = 0; + /* nothing more to do */ +#else /* - * XXX The default CAM transport code is very SCSI-specific and + * The default CAM transport code is very SCSI-specific and * doesn't understand IDE speeds very well. Be silent about it * here and let it default to what is set in XPT_PATH_INQ */ - CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_SUBTRACE, ("GET_TRAN_SETTINGS\n")); cts->valid = (CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID); cts->flags &= ~(CCB_TRANS_DISC_ENB | CCB_TRANS_TAG_ENB); +#endif ccb->ccb_h.status = CAM_REQ_CMP; + CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_SUBTRACE, ("GET_TRAN_SETTINGS\n")); xpt_done(ccb); return; } diff --git a/sys/dev/disk/ncr/ncr.c b/sys/dev/disk/ncr/ncr.c index f19c0dfef7..09b77210a0 100644 --- a/sys/dev/disk/ncr/ncr.c +++ b/sys/dev/disk/ncr/ncr.c @@ -1,7 +1,7 @@ /************************************************************************** ** ** $FreeBSD: src/sys/pci/ncr.c,v 1.155.2.3 2001/03/05 13:09:10 obrien Exp $ -** $DragonFly: src/sys/dev/disk/ncr/ncr.c,v 1.17 2006/12/22 23:26:16 swildner Exp $ +** $DragonFly: src/sys/dev/disk/ncr/ncr.c,v 1.18 2007/12/23 07:00:56 pavalos Exp $ ** ** Device driver for the NCR 53C8XX PCI-SCSI-Controller Family. ** @@ -4186,12 +4186,99 @@ ncr_action (struct cam_sim *sim, union ccb *ccb) break; case XPT_SET_TRAN_SETTINGS: { - struct ccb_trans_settings *cts; + struct ccb_trans_settings *cts = &ccb->cts; tcb_p tp; u_int update_type; +#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; +#endif - cts = &ccb->cts; update_type = 0; +#ifdef CAM_NEW_TRAN_CODE + if (cts->type == CTS_TYPE_CURRENT_SETTINGS) + update_type |= NCR_TRANS_GOAL; + if (cts->type == CTS_TYPE_USER_SETTINGS) + update_type |= NCR_TRANS_USER; + + crit_enter(); + tp = &np->target[ccb->ccb_h.target_id]; + /* Tag and disc enables */ + if ((spi->valid & CTS_SPI_VALID_DISC) != 0) { + if (update_type & NCR_TRANS_GOAL) { + if ((spi->flags & CTS_SPI_FLAGS_DISC_ENB) != 0) + tp->tinfo.disc_tag |= NCR_CUR_DISCENB; + else + tp->tinfo.disc_tag &= ~NCR_CUR_DISCENB; + } + + if (update_type & NCR_TRANS_USER) { + if ((spi->flags & CTS_SPI_FLAGS_DISC_ENB) != 0) + tp->tinfo.disc_tag |= NCR_USR_DISCENB; + else + tp->tinfo.disc_tag &= ~NCR_USR_DISCENB; + } + + } + + if ((scsi->valid & CTS_SCSI_VALID_TQ) != 0) { + if (update_type & NCR_TRANS_GOAL) { + if ((scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) != 0) + tp->tinfo.disc_tag |= NCR_CUR_TAGENB; + else + tp->tinfo.disc_tag &= ~NCR_CUR_TAGENB; + } + + if (update_type & NCR_TRANS_USER) { + if ((scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) != 0) + tp->tinfo.disc_tag |= NCR_USR_TAGENB; + else + tp->tinfo.disc_tag &= ~NCR_USR_TAGENB; + } + } + + /* Filter bus width and sync negotiation settings */ + if ((spi->valid & CTS_SPI_VALID_BUS_WIDTH) != 0) { + if (spi->bus_width > np->maxwide) + spi->bus_width = np->maxwide; + } + + if (((spi->valid & CTS_SPI_VALID_SYNC_RATE) != 0) + || ((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) != 0)) { + if ((spi->valid & CTS_SPI_VALID_SYNC_RATE) != 0) { + if (spi->sync_period != 0 + && (spi->sync_period < np->minsync)) + spi->sync_period = np->minsync; + } + if ((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) != 0) { + if (spi->sync_offset == 0) + spi->sync_period = 0; + if (spi->sync_offset > np->maxoffs) + spi->sync_offset = np->maxoffs; + } + } + if ((update_type & NCR_TRANS_USER) != 0) { + if ((spi->valid & CTS_SPI_VALID_SYNC_RATE) != 0) + tp->tinfo.user.period = spi->sync_period; + if ((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) != 0) + tp->tinfo.user.offset = spi->sync_offset; + if ((spi->valid & CTS_SPI_VALID_BUS_WIDTH) != 0) + tp->tinfo.user.width = spi->bus_width; + } + if ((update_type & NCR_TRANS_GOAL) != 0) { + if ((spi->valid & CTS_SPI_VALID_SYNC_RATE) != 0) + tp->tinfo.goal.period = spi->sync_period; + + if ((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) != 0) + tp->tinfo.goal.offset = spi->sync_offset; + + if ((spi->valid & CTS_SPI_VALID_BUS_WIDTH) != 0) + tp->tinfo.goal.width = spi->bus_width; + } + crit_exit(); +#else if ((cts->flags & CCB_TRANS_CURRENT_SETTINGS) != 0) update_type |= NCR_TRANS_GOAL; if ((cts->flags & CCB_TRANS_USER_SETTINGS) != 0) @@ -4272,6 +4359,7 @@ ncr_action (struct cam_sim *sim, union ccb *ccb) tp->tinfo.goal.width = cts->bus_width; } crit_exit(); +#endif ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); break; @@ -4279,13 +4367,56 @@ ncr_action (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; + struct ccb_trans_settings *cts = &ccb->cts; struct ncr_transinfo *tinfo; - tcb_p tp; + tcb_p tp = &np->target[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; - cts = &ccb->cts; - tp = &np->target[ccb->ccb_h.target_id]; - + crit_enter(); + if (cts->type == CTS_TYPE_CURRENT_SETTINGS) { + tinfo = &tp->tinfo.current; + if (tp->tinfo.disc_tag & NCR_CUR_DISCENB) + spi->flags |= CTS_SPI_FLAGS_DISC_ENB; + else + spi->flags &= ~CTS_SPI_FLAGS_DISC_ENB; + + if (tp->tinfo.disc_tag & NCR_CUR_TAGENB) + scsi->flags |= CTS_SCSI_FLAGS_TAG_ENB; + else + scsi->flags &= ~CTS_SCSI_FLAGS_TAG_ENB; + } else { + tinfo = &tp->tinfo.user; + if (tp->tinfo.disc_tag & NCR_USR_DISCENB) + spi->flags |= CTS_SPI_FLAGS_DISC_ENB; + else + spi->flags &= ~CTS_SPI_FLAGS_DISC_ENB; + + if (tp->tinfo.disc_tag & NCR_USR_TAGENB) + scsi->flags |= CTS_SCSI_FLAGS_TAG_ENB; + else + scsi->flags &= ~CTS_SCSI_FLAGS_TAG_ENB; + } + + spi->sync_period = tinfo->period; + spi->sync_offset = tinfo->offset; + spi->bus_width = tinfo->width; + + crit_exit(); + 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 crit_enter(); if ((cts->flags & CCB_TRANS_CURRENT_SETTINGS) != 0) { tinfo = &tp->tinfo.current; @@ -4322,6 +4453,7 @@ ncr_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); @@ -4389,6 +4521,12 @@ ncr_action (struct cam_sim *sim, union ccb *ccb) strncpy(cpi->hba_vid, "Symbios", 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; @@ -4965,10 +5103,22 @@ ncr_setsync(ncb_p np, nccb_p cp, u_char scntl3, u_char sxfer, u_char period) ** Tell the SCSI layer about the ** new transfer parameters. */ + 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; + neg.xport_specific.spi.sync_period = period; + neg.xport_specific.spi.sync_offset = sxfer & 0x1f; + neg.xport_specific.spi.valid = CTS_SPI_VALID_SYNC_RATE + | CTS_SPI_VALID_SYNC_OFFSET; +#else neg.sync_period = period; neg.sync_offset = sxfer & 0x1f; neg.valid = CCB_TRANS_SYNC_RATE_VALID | CCB_TRANS_SYNC_OFFSET_VALID; +#endif xpt_setup_ccb(&neg.ccb_h, ccb->ccb_h.path, /*priority*/1); xpt_async(AC_TRANSFER_NEG, ccb->ccb_h.path, &neg); @@ -5037,6 +5187,20 @@ static void ncr_setwide (ncb_p np, nccb_p cp, u_char wide, u_char ack) tp->tinfo.wval = scntl3; /* Tell the SCSI layer about the new transfer params */ + 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; + neg.xport_specific.spi.bus_width = (scntl3 & EWS) ? + MSG_EXT_WDTR_BUS_16_BIT : MSG_EXT_WDTR_BUS_8_BIT; + neg.xport_specific.spi.sync_period = 0; + neg.xport_specific.spi.sync_offset = 0; + neg.xport_specific.spi.valid = CTS_SPI_VALID_SYNC_RATE + | CTS_SPI_VALID_SYNC_OFFSET + | CTS_SPI_VALID_BUS_WIDTH; +#else neg.bus_width = (scntl3 & EWS) ? MSG_EXT_WDTR_BUS_16_BIT : MSG_EXT_WDTR_BUS_8_BIT; neg.sync_period = 0; @@ -5044,8 +5208,8 @@ static void ncr_setwide (ncb_p np, nccb_p cp, u_char wide, u_char ack) neg.valid = CCB_TRANS_BUS_WIDTH_VALID | CCB_TRANS_SYNC_RATE_VALID | CCB_TRANS_SYNC_OFFSET_VALID; - xpt_setup_ccb(&neg.ccb_h, ccb->ccb_h.path, - /*priority*/1); +#endif + xpt_setup_ccb(&neg.ccb_h, ccb->ccb_h.path, /*priority*/1); xpt_async(AC_TRANSFER_NEG, ccb->ccb_h.path, &neg); /* diff --git a/sys/dev/disk/sbp/sbp.c b/sys/dev/disk/sbp/sbp.c index fff60af9fb..a6827da972 100644 --- a/sys/dev/disk/sbp/sbp.c +++ b/sys/dev/disk/sbp/sbp.c @@ -32,7 +32,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/firewire/sbp.c,v 1.74 2004/01/08 14:58:09 simokawa Exp $ - * $DragonFly: src/sys/dev/disk/sbp/sbp.c,v 1.25 2007/11/14 18:27:52 swildner Exp $ + * $DragonFly: src/sys/dev/disk/sbp/sbp.c,v 1.26 2007/12/23 07:00:56 pavalos Exp $ * */ @@ -2437,6 +2437,12 @@ END_DEBUG strncpy(cpi->hba_vid, "SBP", HBA_IDLEN); strncpy(cpi->dev_name, sim->sim_name, DEV_IDLEN); cpi->unit_number = sim->unit_number; +#ifdef CAM_NEW_TRAN_CODE + cpi->transport = XPORT_SPI; /* XX should have a FireWire */ + 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); @@ -2445,15 +2451,30 @@ END_DEBUG case XPT_GET_TRAN_SETTINGS: { struct ccb_trans_settings *cts = &ccb->cts; +#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; /* should have a FireWire */ + cts->transport_version = 2; + spi->valid = CTS_SPI_VALID_DISC; + spi->flags = CTS_SPI_FLAGS_DISC_ENB; + scsi->valid = CTS_SCSI_VALID_TQ; + scsi->flags = CTS_SCSI_FLAGS_TAG_ENB; +#else + /* Enable disconnect and tagged queuing */ + cts->valid = CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID; + cts->flags = CCB_TRANS_DISC_ENB | CCB_TRANS_TAG_ENB; +#endif SBP_DEBUG(1) kprintf("%s:%d:%d XPT_GET_TRAN_SETTINGS:.\n", device_get_nameunit(sbp->fd.dev), ccb->ccb_h.target_id, ccb->ccb_h.target_lun); END_DEBUG - /* Enable disconnect and tagged queuing */ - cts->valid = CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID; - cts->flags = CCB_TRANS_DISC_ENB | CCB_TRANS_TAG_ENB; - cts->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); break; diff --git a/sys/dev/disk/trm/trm.c b/sys/dev/disk/trm/trm.c index 82ca2bc23d..281a6e5982 100644 --- a/sys/dev/disk/trm/trm.c +++ b/sys/dev/disk/trm/trm.c @@ -45,7 +45,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/trm/trm.c,v 1.2.2.2 2002/12/19 20:34:45 cognet Exp $ - * $DragonFly: src/sys/dev/disk/trm/trm.c,v 1.14 2006/12/22 23:26:17 swildner Exp $ + * $DragonFly: src/sys/dev/disk/trm/trm.c,v 1.15 2007/12/23 07:00:56 pavalos Exp $ */ /* @@ -647,6 +647,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); } @@ -765,12 +771,67 @@ 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; 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]; + crit_enter(); + /* + * 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); + + crit_exit(); + 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->pDCB[target_id][target_lun]; crit_enter(); /* @@ -814,6 +875,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); } @@ -824,12 +886,97 @@ 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; 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; + crit_enter(); + 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; + } + crit_exit(); +#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; @@ -909,6 +1056,7 @@ trm_action(struct cam_sim *psim, union ccb *pccb) pDCB->tinfo.goal.width = cts->bus_width; } crit_exit(); +#endif pccb->ccb_h.status = CAM_REQ_CMP; xpt_done(pccb); break; diff --git a/sys/dev/raid/aac/aac_cam.c b/sys/dev/raid/aac/aac_cam.c index eca0c1b83f..1f8496f7da 100644 --- a/sys/dev/raid/aac/aac_cam.c +++ b/sys/dev/raid/aac/aac_cam.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/aac/aac_cam.c,v 1.2.2.4 2003/04/08 13:22:08 scottl Exp $ - * $DragonFly: src/sys/dev/raid/aac/aac_cam.c,v 1.6 2006/12/22 23:26:23 swildner Exp $ + * $DragonFly: src/sys/dev/raid/aac/aac_cam.c,v 1.7 2007/12/23 07:00:56 pavalos Exp $ */ /* @@ -231,7 +231,12 @@ aac_cam_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 ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); return; diff --git a/sys/dev/raid/amr/amr_cam.c b/sys/dev/raid/amr/amr_cam.c index ce2cc6f03f..e7258631b1 100644 --- a/sys/dev/raid/amr/amr_cam.c +++ b/sys/dev/raid/amr/amr_cam.c @@ -53,7 +53,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/amr/amr_cam.c,v 1.1.2.3 2002/11/11 13:19:10 emoore Exp $ - * $DragonFly: src/sys/dev/raid/amr/amr_cam.c,v 1.8 2006/10/25 20:56:00 dillon Exp $ + * $DragonFly: src/sys/dev/raid/amr/amr_cam.c,v 1.9 2007/12/23 07:00:56 pavalos Exp $ */ #include @@ -299,6 +299,12 @@ amr_cam_action(struct cam_sim *sim, union ccb *ccb) cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 132 * 1024; /* XXX get from controller? */ +#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; break; @@ -322,12 +328,35 @@ amr_cam_action(struct cam_sim *sim, union ccb *ccb) case XPT_GET_TRAN_SETTINGS: { - struct ccb_trans_settings *cts; + struct ccb_trans_settings *cts = &(ccb->cts); debug(3, "XPT_GET_TRAN_SETTINGS"); - cts = &(ccb->cts); +#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) { + ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; + break; + } + + spi->flags = CTS_SPI_FLAGS_DISC_ENB; + spi->bus_width = MSG_EXT_WDTR_BUS_32_BIT; + spi->sync_period = 6; /* 40MHz how wide is this bus? */ + spi->sync_offset = 31; /* How to extract this from board? */ + + 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 if ((cts->flags & CCB_TRANS_USER_SETTINGS) == 0) { ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; break; @@ -343,6 +372,7 @@ amr_cam_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; break; } diff --git a/sys/dev/raid/asr/asr.c b/sys/dev/raid/asr/asr.c index aa3dad2dc2..4600a1b314 100644 --- a/sys/dev/raid/asr/asr.c +++ b/sys/dev/raid/asr/asr.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/dev/asr/asr.c,v 1.3.2.2 2001/08/23 05:21:29 scottl Exp $ */ -/* $DragonFly: src/sys/dev/raid/asr/asr.c,v 1.30 2007/05/17 21:08:49 dillon Exp $ */ +/* $DragonFly: src/sys/dev/raid/asr/asr.c,v 1.31 2007/12/23 07:00:56 pavalos Exp $ */ /* * Copyright (c) 1996-2000 Distributed Processing Technology Corporation * Copyright (c) 2000-2001 Adaptec Corporation @@ -2915,11 +2915,35 @@ asr_action( case XPT_GET_TRAN_SETTINGS: /* Get default/user set transfer settings for the target */ { - struct ccb_trans_settings *cts; - u_int target_mask; - - cts = &(ccb->cts); - target_mask = 0x01 << ccb->ccb_h.target_id; + struct ccb_trans_settings *cts = &(ccb->cts); +#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; + + if (cts->type == CTS_TYPE_USER_SETTINGS) { + 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; + spi->bus_width = MSG_EXT_WDTR_BUS_16_BIT; + spi->sync_period = 6; /* 40MHz */ + 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; + + ccb->ccb_h.status = CAM_REQ_CMP; + } else { + ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; + } +#else if ((cts->flags & CCB_TRANS_USER_SETTINGS) != 0) { cts->flags = CCB_TRANS_DISC_ENB|CCB_TRANS_TAG_ENB; cts->bus_width = MSG_EXT_WDTR_BUS_16_BIT; @@ -2935,6 +2959,7 @@ asr_action( } else { ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; } +#endif xpt_done(ccb); break; } @@ -3001,6 +3026,12 @@ asr_action( strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); cpi->unit_number = cam_sim_unit(sim); cpi->ccb_h.status = CAM_REQ_CMP; +#ifdef CAM_NEW_TRAN_CODE + cpi->transport = XPORT_SPI; + cpi->transport_version = 2; + cpi->protocol = PROTO_SCSI; + cpi->protocol_version = SCSI_REV_2; +#endif xpt_done(ccb); break; } diff --git a/sys/dev/raid/ciss/ciss.c b/sys/dev/raid/ciss/ciss.c index f67869555f..020dd11851 100644 --- a/sys/dev/raid/ciss/ciss.c +++ b/sys/dev/raid/ciss/ciss.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ciss/ciss.c,v 1.2.2.6 2003/02/18 22:27:41 ps Exp $ - * $DragonFly: src/sys/dev/raid/ciss/ciss.c,v 1.24 2007/05/13 22:25:42 swildner Exp $ + * $DragonFly: src/sys/dev/raid/ciss/ciss.c,v 1.25 2007/12/23 07:00:57 pavalos Exp $ */ /* @@ -2209,6 +2209,12 @@ ciss_cam_action(struct cam_sim *sim, union ccb *ccb) cpi->unit_number = cam_sim_unit(sim); cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 132 * 1024; /* XXX what to set this to? */ +#ifdef CAM_NEW_TRAN_CODE + cpi->transport = XPORT_SPI; + cpi->transport_version = 2; + cpi->protocol = PROTO_SCSI; + cpi->protocol_version = SCSI_REV_2; +#endif ccb->ccb_h.status = CAM_REQ_CMP; break; } @@ -2217,16 +2223,28 @@ ciss_cam_action(struct cam_sim *sim, union ccb *ccb) { struct ccb_trans_settings *cts = &ccb->cts; int bus, target; +#ifdef CAM_NEW_TRAN_CODE + struct ccb_trans_settings_spi *spi = + &cts->xport_specific.spi; +#endif bus = cam_sim_bus(sim); target = cts->ccb_h.target_id; debug(1, "XPT_GET_TRAN_SETTINGS %d:%d", bus, target); - cts->valid = 0; - /* disconnect always OK */ +#ifdef CAM_NEW_TRAN_CODE + cts->protocol = PROTO_SCSI; + cts->protocol_version = SCSI_REV_2; + cts->transport = XPORT_SPI; + cts->transport_version = 2; + + spi->valid = CTS_SPI_VALID_DISC; + spi->flags = CTS_SPI_FLAGS_DISC_ENB; +#else cts->flags |= CCB_TRANS_DISC_ENB; - cts->valid |= CCB_TRANS_DISC_VALID; + cts->valid = CCB_TRANS_DISC_VALID; +#endif cts->ccb_h.status = CAM_REQ_CMP; break; diff --git a/sys/dev/raid/dpt/dpt_scsi.c b/sys/dev/raid/dpt/dpt_scsi.c index 4ace5b032f..8157f41ecc 100644 --- a/sys/dev/raid/dpt/dpt_scsi.c +++ b/sys/dev/raid/dpt/dpt_scsi.c @@ -44,7 +44,7 @@ */ #ident "$FreeBSD: src/sys/dev/dpt/dpt_scsi.c,v 1.28.2.3 2003/01/31 02:47:10 grog Exp $" -#ident "$DragonFly: src/sys/dev/raid/dpt/dpt_scsi.c,v 1.15 2007/07/11 23:46:58 dillon Exp $" +#ident "$DragonFly: src/sys/dev/raid/dpt/dpt_scsi.c,v 1.16 2007/12/23 07:00:57 pavalos Exp $" #define _DPT_C_ @@ -978,11 +978,39 @@ dpt_action(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; +#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; - cts = &ccb->cts; - target_mask = 0x01 << ccb->ccb_h.target_id; + if (cts->type == CTS_TYPE_USER_SETTINGS) { + spi->flags = CTS_SPI_FLAGS_DISC_ENB; + spi->bus_width = (dpt->max_id > 7) + ? MSG_EXT_WDTR_BUS_8_BIT + : MSG_EXT_WDTR_BUS_16_BIT; + spi->sync_period = 25; /* 10MHz */ + if (spi->sync_period != 0) + spi->sync_offset = 15; + scsi->flags = CTS_SCSI_FLAGS_TAG_ENB; + + spi->valid = CTS_SPI_VALID_SYNC_RATE + | CTS_SPI_VALID_SYNC_OFFSET + | CTS_SPI_VALID_SYNC_RATE + | CTS_SPI_VALID_BUS_WIDTH + | CTS_SPI_VALID_DISC; + scsi->valid = CTS_SCSI_VALID_TQ; + ccb->ccb_h.status = CAM_REQ_CMP; + } else { + ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; + } +#else if ((cts->flags & CCB_TRANS_USER_SETTINGS) != 0) { cts->flags = CCB_TRANS_DISC_ENB|CCB_TRANS_TAG_ENB; cts->bus_width = (dpt->max_id > 7) @@ -1002,6 +1030,7 @@ dpt_action(struct cam_sim *sim, union ccb *ccb) } else { ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; } +#endif xpt_done(ccb); break; } @@ -1066,6 +1095,12 @@ dpt_action(struct cam_sim *sim, union ccb *ccb) strncpy(cpi->hba_vid, "DPT", 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; diff --git a/sys/dev/raid/iir/iir.c b/sys/dev/raid/iir/iir.c index 89a562a16c..4904fe135c 100644 --- a/sys/dev/raid/iir/iir.c +++ b/sys/dev/raid/iir/iir.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/dev/iir/iir.c,v 1.2.2.3 2002/05/05 08:18:12 asmodai Exp $ */ -/* $DragonFly: src/sys/dev/raid/iir/iir.c,v 1.18 2007/07/11 23:46:58 dillon Exp $ */ +/* $DragonFly: src/sys/dev/raid/iir/iir.c,v 1.19 2007/12/23 07:00:57 pavalos Exp $ */ /* * Copyright (c) 2000-01 Intel Corporation * All Rights Reserved @@ -1354,11 +1354,34 @@ iir_action( 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; - - cts = &ccb->cts; - target_mask = 0x01 << target; + struct ccb_trans_settings *cts = &ccb->cts; +#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 = CTS_SPI_FLAGS_DISC_ENB; + scsi->flags = CTS_SCSI_FLAGS_TAG_ENB; + spi->bus_width = MSG_EXT_WDTR_BUS_16_BIT; + spi->sync_period = 25; /* 10MHz */ + 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; + ccb->ccb_h.status = CAM_REQ_CMP; + } else { + ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; + } +#else if ((cts->flags & CCB_TRANS_USER_SETTINGS) != 0) { cts->flags = CCB_TRANS_DISC_ENB|CCB_TRANS_TAG_ENB; cts->bus_width = MSG_EXT_WDTR_BUS_16_BIT; @@ -1375,6 +1398,7 @@ iir_action( struct cam_sim *sim, union ccb *ccb ) } else { ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; } +#endif --gdt_stat.io_count_act; xpt_done(ccb); break; @@ -1433,6 +1457,12 @@ iir_action( struct cam_sim *sim, union ccb *ccb ) strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); strncpy(cpi->hba_vid, "Intel Corp.", HBA_IDLEN); strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); +#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; --gdt_stat.io_count_act; xpt_done(ccb); diff --git a/sys/dev/usbmisc/umass/umass.c b/sys/dev/usbmisc/umass/umass.c index 3ebbd99f28..3ca357b58e 100644 --- a/sys/dev/usbmisc/umass/umass.c +++ b/sys/dev/usbmisc/umass/umass.c @@ -26,7 +26,7 @@ * * $NetBSD: umass.c,v 1.28 2000/04/02 23:46:53 augustss Exp $ * $FreeBSD: src/sys/dev/usb/umass.c,v 1.96 2003/12/19 12:19:11 sanpei Exp $ - * $DragonFly: src/sys/dev/usbmisc/umass/umass.c,v 1.30 2007/11/06 07:37:01 hasso Exp $ + * $DragonFly: src/sys/dev/usbmisc/umass/umass.c,v 1.31 2007/12/23 07:00:57 pavalos Exp $ */ /* @@ -2538,13 +2538,21 @@ umass_cam_action(struct cam_sim *sim, union ccb *ccb) case XPT_GET_TRAN_SETTINGS: { struct ccb_trans_settings *cts = &ccb->cts; +#ifdef CAM_NEW_TRAN_CODE + cts->protocol = PROTO_SCSI; + cts->protocol_version = SCSI_REV_2; + cts->transport = XPORT_USB; + cts->transport_version = XPORT_VERSION_UNSPECIFIED; + cts->xport_specific.valid = 0; +#else DPRINTF(UDMASS_SCSI, ("%s:%d:%d:%d:XPT_GET_TRAN_SETTINGS:.\n", device_get_nameunit(sc->sc_dev), cam_sim_path(sc->umass_sim), ccb->ccb_h.target_id, ccb->ccb_h.target_lun)); cts->valid = 0; cts->flags = 0; /* no disconnection, tagging */ +#endif ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); -- 2.11.4.GIT