Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Jun 2011 09:54:48 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r222923 - in stable/8/sys/cam: . ata scsi
Message-ID:  <201106100954.p5A9smf8020428@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Fri Jun 10 09:54:48 2011
New Revision: 222923
URL: http://svn.freebsd.org/changeset/base/222923

Log:
  MFC r220644:
  Make CAM report devices with ATA/SATA transport to devstat(9) as IDE.

Modified:
  stable/8/sys/cam/ata/ata_da.c
  stable/8/sys/cam/cam_ccb.h
  stable/8/sys/cam/scsi/scsi_cd.c
  stable/8/sys/cam/scsi/scsi_ch.c
  stable/8/sys/cam/scsi/scsi_da.c
  stable/8/sys/cam/scsi/scsi_pass.c
  stable/8/sys/cam/scsi/scsi_pt.c
  stable/8/sys/cam/scsi/scsi_sa.c
  stable/8/sys/cam/scsi/scsi_sg.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/cam/ata/ata_da.c
==============================================================================
--- stable/8/sys/cam/ata/ata_da.c	Fri Jun 10 09:51:15 2011	(r222922)
+++ stable/8/sys/cam/ata/ata_da.c	Fri Jun 10 09:54:48 2011	(r222923)
@@ -793,6 +793,12 @@ adaregister(struct cam_periph *periph, v
 	TUNABLE_INT_FETCH(announce_buf, &softc->write_cache);
 	adagetparams(periph, cgd);
 	softc->disk = disk_alloc();
+	softc->disk->d_devstat = devstat_new_entry(periph->periph_name,
+			  periph->unit_number, softc->params.secsize,
+			  DEVSTAT_ALL_SUPPORTED,
+			  DEVSTAT_TYPE_DIRECT |
+			  XPORT_DEVSTAT_TYPE(cpi.transport),
+			  DEVSTAT_PRIORITY_DISK);
 	softc->disk->d_open = adaopen;
 	softc->disk->d_close = adaclose;
 	softc->disk->d_strategy = adastrategy;

Modified: stable/8/sys/cam/cam_ccb.h
==============================================================================
--- stable/8/sys/cam/cam_ccb.h	Fri Jun 10 09:51:15 2011	(r222922)
+++ stable/8/sys/cam/cam_ccb.h	Fri Jun 10 09:54:48 2011	(r222923)
@@ -248,6 +248,14 @@ typedef enum {
 	XPORT_ISCSI,	/* iSCSI */
 } cam_xport;
 
+#define XPORT_IS_ATA(t)		((t) == XPORT_ATA || (t) == XPORT_SATA)
+#define XPORT_IS_SCSI(t)	((t) != XPORT_UNKNOWN && \
+				 (t) != XPORT_UNSPECIFIED && \
+				 !XPORT_IS_ATA(t))
+#define XPORT_DEVSTAT_TYPE(t)	(XPORT_IS_ATA(t) ? DEVSTAT_TYPE_IF_IDE : \
+				 XPORT_IS_SCSI(t) ? DEVSTAT_TYPE_IF_SCSI : \
+				 DEVSTAT_TYPE_IF_OTHER)
+
 #define PROTO_VERSION_UNKNOWN (UINT_MAX - 1)
 #define PROTO_VERSION_UNSPECIFIED UINT_MAX
 #define XPORT_VERSION_UNKNOWN (UINT_MAX - 1)

Modified: stable/8/sys/cam/scsi/scsi_cd.c
==============================================================================
--- stable/8/sys/cam/scsi/scsi_cd.c	Fri Jun 10 09:51:15 2011	(r222922)
+++ stable/8/sys/cam/scsi/scsi_cd.c	Fri Jun 10 09:54:48 2011	(r222923)
@@ -714,10 +714,11 @@ cdregister(struct cam_periph *periph, vo
 	 */
 	cam_periph_unlock(periph);
 	softc->disk = disk_alloc();
-	softc->disk->d_devstat = devstat_new_entry("cd", 
+	softc->disk->d_devstat = devstat_new_entry("cd",
 			  periph->unit_number, 0,
-	  		  DEVSTAT_BS_UNAVAILABLE,
-			  DEVSTAT_TYPE_CDROM | DEVSTAT_TYPE_IF_SCSI,
+			  DEVSTAT_BS_UNAVAILABLE,
+			  DEVSTAT_TYPE_CDROM |
+			  XPORT_DEVSTAT_TYPE(cpi.transport),
 			  DEVSTAT_PRIORITY_CD);
 	softc->disk->d_open = cdopen;
 	softc->disk->d_close = cdclose;

Modified: stable/8/sys/cam/scsi/scsi_ch.c
==============================================================================
--- stable/8/sys/cam/scsi/scsi_ch.c	Fri Jun 10 09:51:15 2011	(r222922)
+++ stable/8/sys/cam/scsi/scsi_ch.c	Fri Jun 10 09:54:48 2011	(r222923)
@@ -322,6 +322,7 @@ chregister(struct cam_periph *periph, vo
 {
 	struct ch_softc *softc;
 	struct ccb_getdev *cgd;
+	struct ccb_pathinq cpi;
 
 	cgd = (struct ccb_getdev *)arg;
 	if (periph == NULL) {
@@ -347,6 +348,11 @@ chregister(struct cam_periph *periph, vo
 	periph->softc = softc;
 	softc->quirks = CH_Q_NONE;
 
+	bzero(&cpi, sizeof(cpi));
+	xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+	cpi.ccb_h.func_code = XPT_PATH_INQ;
+	xpt_action((union ccb *)&cpi);
+
 	/*
 	 * Changers don't have a blocksize, and obviously don't support
 	 * tagged queueing.
@@ -355,7 +361,8 @@ chregister(struct cam_periph *periph, vo
 	softc->device_stats = devstat_new_entry("ch",
 			  periph->unit_number, 0,
 			  DEVSTAT_NO_BLOCKSIZE | DEVSTAT_NO_ORDERED_TAGS,
-			  SID_TYPE(&cgd->inq_data)| DEVSTAT_TYPE_IF_SCSI,
+			  SID_TYPE(&cgd->inq_data) |
+			  XPORT_DEVSTAT_TYPE(cpi.transport),
 			  DEVSTAT_PRIORITY_OTHER);
 
 	/* Register the device */

Modified: stable/8/sys/cam/scsi/scsi_da.c
==============================================================================
--- stable/8/sys/cam/scsi/scsi_da.c	Fri Jun 10 09:51:15 2011	(r222922)
+++ stable/8/sys/cam/scsi/scsi_da.c	Fri Jun 10 09:54:48 2011	(r222923)
@@ -1266,6 +1266,12 @@ daregister(struct cam_periph *periph, vo
 
 	mtx_unlock(periph->sim->mtx);
 	softc->disk = disk_alloc();
+	softc->disk->d_devstat = devstat_new_entry(periph->periph_name,
+			  periph->unit_number, 0,
+			  DEVSTAT_BS_UNAVAILABLE,
+			  SID_TYPE(&cgd->inq_data) |
+			  XPORT_DEVSTAT_TYPE(cpi.transport),
+			  DEVSTAT_PRIORITY_DISK);
 	softc->disk->d_open = daopen;
 	softc->disk->d_close = daclose;
 	softc->disk->d_strategy = dastrategy;

Modified: stable/8/sys/cam/scsi/scsi_pass.c
==============================================================================
--- stable/8/sys/cam/scsi/scsi_pass.c	Fri Jun 10 09:51:15 2011	(r222922)
+++ stable/8/sys/cam/scsi/scsi_pass.c	Fri Jun 10 09:54:48 2011	(r222923)
@@ -230,6 +230,7 @@ passregister(struct cam_periph *periph, 
 {
 	struct pass_softc *softc;
 	struct ccb_getdev *cgd;
+	struct ccb_pathinq cpi;
 	int    no_tags;
 
 	cgd = (struct ccb_getdev *)arg;
@@ -254,10 +255,20 @@ passregister(struct cam_periph *periph, 
 
 	bzero(softc, sizeof(*softc));
 	softc->state = PASS_STATE_NORMAL;
-	softc->pd_type = SID_TYPE(&cgd->inq_data);
+	if (cgd->protocol == PROTO_SCSI || cgd->protocol == PROTO_ATAPI)
+		softc->pd_type = SID_TYPE(&cgd->inq_data);
+	else if (cgd->protocol == PROTO_SATAPM)
+		softc->pd_type = T_ENCLOSURE;
+	else
+		softc->pd_type = T_DIRECT;
 
 	periph->softc = softc;
 
+	bzero(&cpi, sizeof(cpi));
+	xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+	cpi.ccb_h.func_code = XPT_PATH_INQ;
+	xpt_action((union ccb *)&cpi);
+
 	/*
 	 * We pass in 0 for a blocksize, since we don't 
 	 * know what the blocksize of this device is, if 
@@ -270,7 +281,7 @@ passregister(struct cam_periph *periph, 
 			  DEVSTAT_NO_BLOCKSIZE
 			  | (no_tags ? DEVSTAT_NO_ORDERED_TAGS : 0),
 			  softc->pd_type |
-			  DEVSTAT_TYPE_IF_SCSI |
+			  XPORT_DEVSTAT_TYPE(cpi.transport) |
 			  DEVSTAT_TYPE_PASS,
 			  DEVSTAT_PRIORITY_PASS);
 

Modified: stable/8/sys/cam/scsi/scsi_pt.c
==============================================================================
--- stable/8/sys/cam/scsi/scsi_pt.c	Fri Jun 10 09:51:15 2011	(r222922)
+++ stable/8/sys/cam/scsi/scsi_pt.c	Fri Jun 10 09:54:48 2011	(r222923)
@@ -252,6 +252,7 @@ ptctor(struct cam_periph *periph, void *
 {
 	struct pt_softc *softc;
 	struct ccb_getdev *cgd;
+	struct ccb_pathinq cpi;
 
 	cgd = (struct ccb_getdev *)arg;
 	if (periph == NULL) {
@@ -280,12 +281,18 @@ ptctor(struct cam_periph *periph, void *
 	softc->io_timeout = SCSI_PT_DEFAULT_TIMEOUT * 1000;
 
 	periph->softc = softc;
-	
+
+	bzero(&cpi, sizeof(cpi));
+	xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+	cpi.ccb_h.func_code = XPT_PATH_INQ;
+	xpt_action((union ccb *)&cpi);
+
 	cam_periph_unlock(periph);
 	softc->device_stats = devstat_new_entry("pt",
 			  periph->unit_number, 0,
 			  DEVSTAT_NO_BLOCKSIZE,
-			  SID_TYPE(&cgd->inq_data) | DEVSTAT_TYPE_IF_SCSI,
+			  SID_TYPE(&cgd->inq_data) |
+			  XPORT_DEVSTAT_TYPE(cpi.transport),
 			  DEVSTAT_PRIORITY_OTHER);
 
 	softc->dev = make_dev(&pt_cdevsw, periph->unit_number, UID_ROOT,

Modified: stable/8/sys/cam/scsi/scsi_sa.c
==============================================================================
--- stable/8/sys/cam/scsi/scsi_sa.c	Fri Jun 10 09:51:15 2011	(r222922)
+++ stable/8/sys/cam/scsi/scsi_sa.c	Fri Jun 10 09:54:48 2011	(r222923)
@@ -1431,6 +1431,7 @@ saregister(struct cam_periph *periph, vo
 {
 	struct sa_softc *softc;
 	struct ccb_getdev *cgd;
+	struct ccb_pathinq cpi;
 	caddr_t match;
 	int i;
 	
@@ -1479,15 +1480,20 @@ saregister(struct cam_periph *periph, vo
 	} else
 		softc->quirks = SA_QUIRK_NONE;
 
+	bzero(&cpi, sizeof(cpi));
+	xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+	cpi.ccb_h.func_code = XPT_PATH_INQ;
+	xpt_action((union ccb *)&cpi);
+
 	/*
- 	 * The SA driver supports a blocksize, but we don't know the
+	 * The SA driver supports a blocksize, but we don't know the
 	 * blocksize until we media is inserted.  So, set a flag to
 	 * indicate that the blocksize is unavailable right now.
 	 */
 	cam_periph_unlock(periph);
 	softc->device_stats = devstat_new_entry("sa", periph->unit_number, 0,
 	    DEVSTAT_BS_UNAVAILABLE, SID_TYPE(&cgd->inq_data) |
-	    DEVSTAT_TYPE_IF_SCSI, DEVSTAT_PRIORITY_TAPE);
+	    XPORT_DEVSTAT_TYPE(cpi.transport), DEVSTAT_PRIORITY_TAPE);
 
 	softc->devs.ctl_dev = make_dev(&sa_cdevsw, SAMINOR(SA_CTLDEV,
 	    0, SA_ATYPE_R), UID_ROOT, GID_OPERATOR,

Modified: stable/8/sys/cam/scsi/scsi_sg.c
==============================================================================
--- stable/8/sys/cam/scsi/scsi_sg.c	Fri Jun 10 09:51:15 2011	(r222922)
+++ stable/8/sys/cam/scsi/scsi_sg.c	Fri Jun 10 09:54:48 2011	(r222923)
@@ -258,6 +258,7 @@ sgregister(struct cam_periph *periph, vo
 {
 	struct sg_softc *softc;
 	struct ccb_getdev *cgd;
+	struct ccb_pathinq cpi;
 	int no_tags;
 
 	cgd = (struct ccb_getdev *)arg;
@@ -284,6 +285,11 @@ sgregister(struct cam_periph *periph, vo
 	TAILQ_INIT(&softc->rdwr_done);
 	periph->softc = softc;
 
+	bzero(&cpi, sizeof(cpi));
+	xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+	cpi.ccb_h.func_code = XPT_PATH_INQ;
+	xpt_action((union ccb *)&cpi);
+
 	/*
 	 * We pass in 0 for all blocksize, since we don't know what the
 	 * blocksize of the device is, if it even has a blocksize.
@@ -295,7 +301,7 @@ sgregister(struct cam_periph *periph, vo
 			DEVSTAT_NO_BLOCKSIZE
 			| (no_tags ? DEVSTAT_NO_ORDERED_TAGS : 0),
 			softc->pd_type |
-			DEVSTAT_TYPE_IF_SCSI |
+			XPORT_DEVSTAT_TYPE(cpi.transport) |
 			DEVSTAT_TYPE_PASS,
 			DEVSTAT_PRIORITY_PASS);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201106100954.p5A9smf8020428>