Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add a bustype_async_event_xfer_mode() callback to scsipi...
details: https://anonhg.NetBSD.org/src/rev/4f2e0e73afda
branches: trunk
changeset: 778927:4f2e0e73afda
user: bouyer <bouyer%NetBSD.org@localhost>
date: Fri Apr 20 20:23:20 2012 +0000
description:
Add a bustype_async_event_xfer_mode() callback to scsipi_bustype (which can
be NULL), so that transport-specific details of transfer mode setting/printing
can be handled more easily.
Move scsipi_async_event_xfer_mode() and scsipi_print_xfer_mode() to
scsi_base.c and split in parallel scsi and FC/SAS parts.
size of struct scsipi_bustype has changed, welcome to 6.99.5
diffstat:
sys/dev/ic/ahcisata_core.c | 5 +-
sys/dev/ic/mvsata.c | 5 +-
sys/dev/ic/siisata.c | 7 +-
sys/dev/scsipi/atapi_wdc.c | 5 +-
sys/dev/scsipi/scsi_base.c | 147 ++++++++++++++++++++++++++++++++++++++++++-
sys/dev/scsipi/scsiconf.c | 8 +-
sys/dev/scsipi/scsiconf.h | 10 ++-
sys/dev/scsipi/scsipi_base.c | 135 +-------------------------------------
sys/dev/scsipi/scsipiconf.h | 11 +--
sys/dev/usb/umass_scsipi.c | 5 +-
sys/sys/param.h | 4 +-
11 files changed, 187 insertions(+), 155 deletions(-)
diffs (truncated from 618 to 300 lines):
diff -r e277060b0bc5 -r 4f2e0e73afda sys/dev/ic/ahcisata_core.c
--- a/sys/dev/ic/ahcisata_core.c Fri Apr 20 18:35:28 2012 +0000
+++ b/sys/dev/ic/ahcisata_core.c Fri Apr 20 20:23:20 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ahcisata_core.c,v 1.33 2012/01/10 01:43:05 jakllsch Exp $ */
+/* $NetBSD: ahcisata_core.c,v 1.34 2012/04/20 20:23:20 bouyer Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.33 2012/01/10 01:43:05 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.34 2012/04/20 20:23:20 bouyer Exp $");
#include <sys/types.h>
#include <sys/malloc.h>
@@ -92,6 +92,7 @@
atapi_interpret_sense,
atapi_print_addr,
ahci_atapi_kill_pending,
+ NULL,
};
#endif /* NATAPIBUS */
diff -r e277060b0bc5 -r 4f2e0e73afda sys/dev/ic/mvsata.c
--- a/sys/dev/ic/mvsata.c Fri Apr 20 18:35:28 2012 +0000
+++ b/sys/dev/ic/mvsata.c Fri Apr 20 20:23:20 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mvsata.c,v 1.15 2012/01/24 20:04:08 jakllsch Exp $ */
+/* $NetBSD: mvsata.c,v 1.16 2012/04/20 20:23:20 bouyer Exp $ */
/*
* Copyright (c) 2008 KIYOHARA Takashi
* All rights reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.15 2012/01/24 20:04:08 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mvsata.c,v 1.16 2012/04/20 20:23:20 bouyer Exp $");
#include "opt_mvsata.h"
@@ -220,6 +220,7 @@
atapi_interpret_sense,
atapi_print_addr,
mvsata_atapi_kill_pending,
+ NULL,
};
#endif /* NATAPIBUS */
#endif
diff -r e277060b0bc5 -r 4f2e0e73afda sys/dev/ic/siisata.c
--- a/sys/dev/ic/siisata.c Fri Apr 20 18:35:28 2012 +0000
+++ b/sys/dev/ic/siisata.c Fri Apr 20 20:23:20 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: siisata.c,v 1.15 2011/09/27 01:02:38 jym Exp $ */
+/* $NetBSD: siisata.c,v 1.16 2012/04/20 20:23:20 bouyer Exp $ */
/* from ahcisata_core.c */
@@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.15 2011/09/27 01:02:38 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.16 2012/04/20 20:23:20 bouyer Exp $");
#include <sys/types.h>
#include <sys/malloc.h>
@@ -172,7 +172,8 @@
atapi_scsipi_cmd,
atapi_interpret_sense,
atapi_print_addr,
- siisata_atapi_kill_pending
+ siisata_atapi_kill_pending,
+ NULL,
};
#endif /* NATAPIBUS */
diff -r e277060b0bc5 -r 4f2e0e73afda sys/dev/scsipi/atapi_wdc.c
--- a/sys/dev/scsipi/atapi_wdc.c Fri Apr 20 18:35:28 2012 +0000
+++ b/sys/dev/scsipi/atapi_wdc.c Fri Apr 20 20:23:20 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atapi_wdc.c,v 1.112 2011/05/24 16:35:26 joerg Exp $ */
+/* $NetBSD: atapi_wdc.c,v 1.113 2012/04/20 20:23:21 bouyer Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer.
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.112 2011/05/24 16:35:26 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.113 2012/04/20 20:23:21 bouyer Exp $");
#ifndef ATADEBUG
#define ATADEBUG
@@ -102,6 +102,7 @@
atapi_interpret_sense,
atapi_print_addr,
wdc_atapi_kill_pending,
+ NULL,
};
void
diff -r e277060b0bc5 -r 4f2e0e73afda sys/dev/scsipi/scsi_base.c
--- a/sys/dev/scsipi/scsi_base.c Fri Apr 20 18:35:28 2012 +0000
+++ b/sys/dev/scsipi/scsi_base.c Fri Apr 20 20:23:20 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: scsi_base.c,v 1.89 2008/04/28 20:23:57 martin Exp $ */
+/* $NetBSD: scsi_base.c,v 1.90 2012/04/20 20:23:21 bouyer Exp $ */
/*-
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsi_base.c,v 1.89 2008/04/28 20:23:57 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsi_base.c,v 1.90 2012/04/20 20:23:21 bouyer Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -48,6 +48,7 @@
#include <dev/scsipi/scsiconf.h>
#include <dev/scsipi/scsipi_base.h>
+static void scsi_print_xfer_mode(struct scsipi_periph *);
/*
* Do a scsi operation, asking a device to run as SCSI-II if it can.
*/
@@ -116,3 +117,145 @@
scsi_kill_pending(struct scsipi_periph *periph)
{
}
+
+/*
+ * scsi_print_xfer_mode:
+ *
+ * Print a parallel SCSI periph's capabilities.
+ */
+static void
+scsi_print_xfer_mode(struct scsipi_periph *periph)
+{
+ int period, freq, speed, mbs;
+
+ aprint_normal_dev(periph->periph_dev, "");
+ if (periph->periph_mode & (PERIPH_CAP_SYNC | PERIPH_CAP_DT)) {
+ period = scsipi_sync_factor_to_period(periph->periph_period);
+ aprint_normal("sync (%d.%02dns offset %d)",
+ period / 100, period % 100, periph->periph_offset);
+ } else
+ aprint_normal("async");
+
+ if (periph->periph_mode & PERIPH_CAP_WIDE32)
+ aprint_normal(", 32-bit");
+ else if (periph->periph_mode & (PERIPH_CAP_WIDE16 | PERIPH_CAP_DT))
+ aprint_normal(", 16-bit");
+ else
+ aprint_normal(", 8-bit");
+
+ if (periph->periph_mode & (PERIPH_CAP_SYNC | PERIPH_CAP_DT)) {
+ freq = scsipi_sync_factor_to_freq(periph->periph_period);
+ speed = freq;
+ if (periph->periph_mode & PERIPH_CAP_WIDE32)
+ speed *= 4;
+ else if (periph->periph_mode &
+ (PERIPH_CAP_WIDE16 | PERIPH_CAP_DT))
+ speed *= 2;
+ mbs = speed / 1000;
+ if (mbs > 0) {
+ aprint_normal(" (%d.%03dMB/s)", mbs,
+ speed % 1000);
+ } else
+ aprint_normal(" (%dKB/s)", speed % 1000);
+ }
+
+ aprint_normal(" transfers");
+
+ if (periph->periph_mode & PERIPH_CAP_TQING)
+ aprint_normal(", tagged queueing");
+
+ aprint_normal("\n");
+}
+
+/*
+ * scsi_async_event_xfer_mode:
+ *
+ * Update the xfer mode for all parallel SCSI periphs sharing the
+ * specified I_T Nexus.
+ */
+void
+scsi_async_event_xfer_mode(struct scsipi_channel *chan, void *arg)
+{
+ struct scsipi_xfer_mode *xm = arg;
+ struct scsipi_periph *periph;
+ int lun, announce, mode, period, offset;
+
+ for (lun = 0; lun < chan->chan_nluns; lun++) {
+ periph = scsipi_lookup_periph(chan, xm->xm_target, lun);
+ if (periph == NULL)
+ continue;
+ announce = 0;
+
+ /*
+ * Clamp the xfer mode down to this periph's capabilities.
+ */
+ mode = xm->xm_mode & periph->periph_cap;
+ if (mode & PERIPH_CAP_SYNC) {
+ period = xm->xm_period;
+ offset = xm->xm_offset;
+ } else {
+ period = 0;
+ offset = 0;
+ }
+
+ /*
+ * If we do not have a valid xfer mode yet, or the parameters
+ * are different, announce them.
+ */
+ if ((periph->periph_flags & PERIPH_MODE_VALID) == 0 ||
+ periph->periph_mode != mode ||
+ periph->periph_period != period ||
+ periph->periph_offset != offset)
+ announce = 1;
+
+ periph->periph_mode = mode;
+ periph->periph_period = period;
+ periph->periph_offset = offset;
+ periph->periph_flags |= PERIPH_MODE_VALID;
+
+ if (announce)
+ scsi_print_xfer_mode(periph);
+ }
+}
+
+/*
+ * scsipi_async_event_xfer_mode:
+ *
+ * Update the xfer mode for all SAS/FC periphs sharing the
+ * specified I_T Nexus.
+ */
+void
+scsi_fc_sas_async_event_xfer_mode(struct scsipi_channel *chan, void *arg)
+{
+ struct scsipi_xfer_mode *xm = arg;
+ struct scsipi_periph *periph;
+ int lun, announce, mode;
+
+ for (lun = 0; lun < chan->chan_nluns; lun++) {
+ periph = scsipi_lookup_periph(chan, xm->xm_target, lun);
+ if (periph == NULL)
+ continue;
+ announce = 0;
+
+ /*
+ * Clamp the xfer mode down to this periph's capabilities.
+ */
+ mode = xm->xm_mode & periph->periph_cap;
+ /*
+ * If we do not have a valid xfer mode yet, or the parameters
+ * are different, announce them.
+ */
+ if ((periph->periph_flags & PERIPH_MODE_VALID) == 0 ||
+ periph->periph_mode != mode)
+ announce = 1;
+
+ periph->periph_mode = mode;
+ periph->periph_flags |= PERIPH_MODE_VALID;
+
+ if (announce &&
+ (periph->periph_mode & PERIPH_CAP_TQING) != 0) {
+ aprint_normal_dev(periph->periph_dev,
+ "tagged queueing\n");
+ }
+ }
+}
diff -r e277060b0bc5 -r 4f2e0e73afda sys/dev/scsipi/scsiconf.c
--- a/sys/dev/scsipi/scsiconf.c Fri Apr 20 18:35:28 2012 +0000
+++ b/sys/dev/scsipi/scsiconf.c Fri Apr 20 20:23:20 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: scsiconf.c,v 1.266 2012/04/19 17:45:20 bouyer Exp $ */
+/* $NetBSD: scsiconf.c,v 1.267 2012/04/20 20:23:21 bouyer Exp $ */
/*-
* Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.266 2012/04/19 17:45:20 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.267 2012/04/20 20:23:21 bouyer Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -119,6 +119,7 @@
scsipi_interpret_sense,
scsi_print_addr,
scsi_kill_pending,
Home |
Main Index |
Thread Index |
Old Index