Author: mav
Date: Thu Apr 14 21:25:32 2011
New Revision: 220644
URL: http://svn.freebsd.org/changeset/base/220644

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

Modified:
  head/sys/cam/ata/ata_da.c
  head/sys/cam/cam_ccb.h
  head/sys/cam/scsi/scsi_cd.c
  head/sys/cam/scsi/scsi_ch.c
  head/sys/cam/scsi/scsi_da.c
  head/sys/cam/scsi/scsi_pass.c
  head/sys/cam/scsi/scsi_pt.c
  head/sys/cam/scsi/scsi_sa.c
  head/sys/cam/scsi/scsi_sg.c

Modified: head/sys/cam/ata/ata_da.c
==============================================================================
--- head/sys/cam/ata/ata_da.c   Thu Apr 14 20:06:23 2011        (r220643)
+++ head/sys/cam/ata/ata_da.c   Thu Apr 14 21:25:32 2011        (r220644)
@@ -792,6 +792,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: head/sys/cam/cam_ccb.h
==============================================================================
--- head/sys/cam/cam_ccb.h      Thu Apr 14 20:06:23 2011        (r220643)
+++ head/sys/cam/cam_ccb.h      Thu Apr 14 21:25:32 2011        (r220644)
@@ -258,6 +258,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: head/sys/cam/scsi/scsi_cd.c
==============================================================================
--- head/sys/cam/scsi/scsi_cd.c Thu Apr 14 20:06:23 2011        (r220643)
+++ head/sys/cam/scsi/scsi_cd.c Thu Apr 14 21:25:32 2011        (r220644)
@@ -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: head/sys/cam/scsi/scsi_ch.c
==============================================================================
--- head/sys/cam/scsi/scsi_ch.c Thu Apr 14 20:06:23 2011        (r220643)
+++ head/sys/cam/scsi/scsi_ch.c Thu Apr 14 21:25:32 2011        (r220644)
@@ -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: head/sys/cam/scsi/scsi_da.c
==============================================================================
--- head/sys/cam/scsi/scsi_da.c Thu Apr 14 20:06:23 2011        (r220643)
+++ head/sys/cam/scsi/scsi_da.c Thu Apr 14 21:25:32 2011        (r220644)
@@ -1292,6 +1292,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: head/sys/cam/scsi/scsi_pass.c
==============================================================================
--- head/sys/cam/scsi/scsi_pass.c       Thu Apr 14 20:06:23 2011        
(r220643)
+++ head/sys/cam/scsi/scsi_pass.c       Thu Apr 14 21:25:32 2011        
(r220644)
@@ -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: head/sys/cam/scsi/scsi_pt.c
==============================================================================
--- head/sys/cam/scsi/scsi_pt.c Thu Apr 14 20:06:23 2011        (r220643)
+++ head/sys/cam/scsi/scsi_pt.c Thu Apr 14 21:25:32 2011        (r220644)
@@ -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: head/sys/cam/scsi/scsi_sa.c
==============================================================================
--- head/sys/cam/scsi/scsi_sa.c Thu Apr 14 20:06:23 2011        (r220643)
+++ head/sys/cam/scsi/scsi_sa.c Thu Apr 14 21:25:32 2011        (r220644)
@@ -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: head/sys/cam/scsi/scsi_sg.c
==============================================================================
--- head/sys/cam/scsi/scsi_sg.c Thu Apr 14 20:06:23 2011        (r220643)
+++ head/sys/cam/scsi/scsi_sg.c Thu Apr 14 21:25:32 2011        (r220644)
@@ -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);
 
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to