summaryrefslogtreecommitdiffstats
path: root/sys/cam
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2011-04-14 21:25:32 +0000
committermav <mav@FreeBSD.org>2011-04-14 21:25:32 +0000
commit9bc238fc0334cfb46f05799c73b4c2e354eb9be4 (patch)
tree71bd2fcd06915bd43a64124900a2385aa575a77a /sys/cam
parentc1a81e0659dd1202f6a4ec7b68ae949d74264b48 (diff)
downloadFreeBSD-src-9bc238fc0334cfb46f05799c73b4c2e354eb9be4.zip
FreeBSD-src-9bc238fc0334cfb46f05799c73b4c2e354eb9be4.tar.gz
Make CAM report devices with ATA/SATA transport to devstat(9) as IDE.
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/ata/ata_da.c6
-rw-r--r--sys/cam/cam_ccb.h8
-rw-r--r--sys/cam/scsi/scsi_cd.c7
-rw-r--r--sys/cam/scsi/scsi_ch.c9
-rw-r--r--sys/cam/scsi/scsi_da.c6
-rw-r--r--sys/cam/scsi/scsi_pass.c15
-rw-r--r--sys/cam/scsi/scsi_pt.c11
-rw-r--r--sys/cam/scsi/scsi_sa.c10
-rw-r--r--sys/cam/scsi/scsi_sg.c8
9 files changed, 69 insertions, 11 deletions
diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c
index 8f5d53e..33bd426 100644
--- a/sys/cam/ata/ata_da.c
+++ b/sys/cam/ata/ata_da.c
@@ -792,6 +792,12 @@ adaregister(struct cam_periph *periph, void *arg)
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;
diff --git a/sys/cam/cam_ccb.h b/sys/cam/cam_ccb.h
index bee07e8..981a5ed 100644
--- a/sys/cam/cam_ccb.h
+++ b/sys/cam/cam_ccb.h
@@ -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)
diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c
index 4c49e2d3..6dc836f 100644
--- a/sys/cam/scsi/scsi_cd.c
+++ b/sys/cam/scsi/scsi_cd.c
@@ -714,10 +714,11 @@ cdregister(struct cam_periph *periph, void *arg)
*/
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;
diff --git a/sys/cam/scsi/scsi_ch.c b/sys/cam/scsi/scsi_ch.c
index 107f22b..4d33cd9 100644
--- a/sys/cam/scsi/scsi_ch.c
+++ b/sys/cam/scsi/scsi_ch.c
@@ -322,6 +322,7 @@ chregister(struct cam_periph *periph, void *arg)
{
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, void *arg)
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, void *arg)
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 */
diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c
index 7790177..61c7934 100644
--- a/sys/cam/scsi/scsi_da.c
+++ b/sys/cam/scsi/scsi_da.c
@@ -1292,6 +1292,12 @@ daregister(struct cam_periph *periph, void *arg)
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;
diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c
index 2941136..e7ecb35 100644
--- a/sys/cam/scsi/scsi_pass.c
+++ b/sys/cam/scsi/scsi_pass.c
@@ -230,6 +230,7 @@ passregister(struct cam_periph *periph, void *arg)
{
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, void *arg)
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, void *arg)
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);
diff --git a/sys/cam/scsi/scsi_pt.c b/sys/cam/scsi/scsi_pt.c
index 3421750..1abb45e 100644
--- a/sys/cam/scsi/scsi_pt.c
+++ b/sys/cam/scsi/scsi_pt.c
@@ -252,6 +252,7 @@ ptctor(struct cam_periph *periph, void *arg)
{
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 *arg)
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,
diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c
index 331f9a2..0d3ef1a 100644
--- a/sys/cam/scsi/scsi_sa.c
+++ b/sys/cam/scsi/scsi_sa.c
@@ -1431,6 +1431,7 @@ saregister(struct cam_periph *periph, void *arg)
{
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, void *arg)
} 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,
diff --git a/sys/cam/scsi/scsi_sg.c b/sys/cam/scsi/scsi_sg.c
index 09d30a6..2a989e7 100644
--- a/sys/cam/scsi/scsi_sg.c
+++ b/sys/cam/scsi/scsi_sg.c
@@ -258,6 +258,7 @@ sgregister(struct cam_periph *periph, void *arg)
{
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, void *arg)
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, void *arg)
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);
OpenPOWER on IntegriCloud