From owner-svn-src-all@FreeBSD.ORG Sat Oct 31 10:47:47 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EB2E0106568F; Sat, 31 Oct 2009 10:47:47 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DABEE8FC1B; Sat, 31 Oct 2009 10:47:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n9VAllox083914; Sat, 31 Oct 2009 10:47:47 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n9VAllqg083912; Sat, 31 Oct 2009 10:47:47 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200910311047.n9VAllqg083912@svn.freebsd.org> From: Alexander Motin Date: Sat, 31 Oct 2009 10:47:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r198709 - head/sbin/camcontrol X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2009 10:47:48 -0000 Author: mav Date: Sat Oct 31 10:47:47 2009 New Revision: 198709 URL: http://svn.freebsd.org/changeset/base/198709 Log: MFp4: Sync connection speed reporting with kernel. Report speed in identify command, same as done by inquiry. Modified: head/sbin/camcontrol/camcontrol.c Modified: head/sbin/camcontrol/camcontrol.c ============================================================================== --- head/sbin/camcontrol/camcontrol.c Sat Oct 31 10:43:38 2009 (r198708) +++ head/sbin/camcontrol/camcontrol.c Sat Oct 31 10:47:47 2009 (r198709) @@ -186,7 +186,7 @@ static int scsidoinquiry(struct cam_devi char *combinedopt, int retry_count, int timeout); static int scsiinquiry(struct cam_device *device, int retry_count, int timeout); static int scsiserial(struct cam_device *device, int retry_count, int timeout); -static int scsixferrate(struct cam_device *device); +static int camxferrate(struct cam_device *device); #endif /* MINIMALISTIC */ static int parse_btl(char *tstr, int *bus, int *target, int *lun, cam_argmask *arglst); @@ -663,7 +663,7 @@ scsidoinquiry(struct cam_device *device, return(error); if (arglist & CAM_ARG_GET_XFERRATE) - error = scsixferrate(device); + error = camxferrate(device); return(error); } @@ -873,14 +873,18 @@ scsiserial(struct cam_device *device, in } static int -scsixferrate(struct cam_device *device) +camxferrate(struct cam_device *device) { + struct ccb_pathinq cpi; u_int32_t freq = 0; u_int32_t speed = 0; union ccb *ccb; u_int mb; int retval = 0; + if ((retval = get_cpi(device, &cpi)) != 0) + return (1); + ccb = cam_getccb(device); if (ccb == NULL) { @@ -913,6 +917,8 @@ scsixferrate(struct cam_device *device) } + speed = cpi.base_transfer_speed; + freq = 0; if (ccb->cts.transport == XPORT_SPI) { struct ccb_trans_settings_spi *spi = &ccb->cts.xport_specific.spi; @@ -920,31 +926,44 @@ scsixferrate(struct cam_device *device) if ((spi->valid & CTS_SPI_VALID_SYNC_RATE) != 0) { freq = scsi_calc_syncsrate(spi->sync_period); speed = freq; - } else { - struct ccb_pathinq cpi; - - retval = get_cpi(device, &cpi); - if (retval == 0) { - speed = cpi.base_transfer_speed; - freq = 0; - } } - - fprintf(stdout, "%s%d: ", device->device_name, - device->dev_unit_num); - if ((spi->valid & CTS_SPI_VALID_BUS_WIDTH) != 0) { speed *= (0x01 << spi->bus_width); } + } else if (ccb->cts.transport == XPORT_FC) { + struct ccb_trans_settings_fc *fc = + &ccb->cts.xport_specific.fc; + + if (fc->valid & CTS_FC_VALID_SPEED) + speed = fc->bitrate; + } else if (ccb->cts.transport == XPORT_SAS) { + struct ccb_trans_settings_sas *sas = + &ccb->cts.xport_specific.sas; + + if (sas->valid & CTS_SAS_VALID_SPEED) + speed = sas->bitrate; + } else if (ccb->cts.transport == XPORT_SATA) { + struct ccb_trans_settings_sata *sata = + &ccb->cts.xport_specific.sata; + + if (sata->valid & CTS_SATA_VALID_SPEED) + speed = sata->bitrate; + } + + mb = speed / 1000; + if (mb > 0) { + fprintf(stdout, "%s%d: %d.%03dMB/s transfers ", + device->device_name, device->dev_unit_num, + mb, speed % 1000); + } else { + fprintf(stdout, "%s%d: %dKB/s transfers ", + device->device_name, device->dev_unit_num, + speed); + } - mb = speed / 1000; - - if (mb > 0) - fprintf(stdout, "%d.%03dMB/s transfers ", - mb, speed % 1000); - else - fprintf(stdout, "%dKB/s transfers ", - speed); + if (ccb->cts.transport == XPORT_SPI) { + struct ccb_trans_settings_spi *spi = + &ccb->cts.xport_specific.spi; if (((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) != 0) && (spi->sync_offset != 0)) @@ -964,25 +983,22 @@ scsixferrate(struct cam_device *device) && (spi->sync_offset != 0)) { fprintf(stdout, ")"); } - } else { - struct ccb_pathinq cpi; - - retval = get_cpi(device, &cpi); - - if (retval != 0) - goto xferrate_bailout; - - speed = cpi.base_transfer_speed; - freq = 0; - - mb = speed / 1000; - - if (mb > 0) - fprintf(stdout, "%d.%03dMB/s transfers ", - mb, speed % 1000); - else - fprintf(stdout, "%dKB/s transfers ", - speed); + } else if (ccb->cts.transport == XPORT_ATA) { + struct ccb_trans_settings_ata *ata = + &ccb->cts.xport_specific.ata; + + if (ata->valid & CTS_ATA_VALID_BYTECOUNT) { + fprintf(stdout, "(PIO size %dbytes)", + ata->bytecount); + } + } else if (ccb->cts.transport == XPORT_SATA) { + struct ccb_trans_settings_sata *sata = + &ccb->cts.xport_specific.sata; + + if (sata->valid & CTS_SATA_VALID_BYTECOUNT) { + fprintf(stdout, "(PIO size %dbytes)", + sata->bytecount); + } } if (ccb->cts.protocol == PROTO_SCSI) { @@ -1305,6 +1321,7 @@ ataidentify(struct cam_device *device, i fprintf(stdout, "%s%d: ", device->device_name, device->dev_unit_num); ata_print_ident(ident_buf); + camxferrate(device); atacapprint(ident_buf); free(ident_buf);