Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Expand struct scsipi_bustype {} in a ABI-backward-co...



details:   https://anonhg.NetBSD.org/src/rev/6c2508e8a17d
branches:  trunk
changeset: 778903:6c2508e8a17d
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Thu Apr 19 17:45:20 2012 +0000

description:
Expand struct scsipi_bustype {} in a ABI-backward-compatible way to
pass more informations about the bus:
- bustype_type has 2 different bytes, one holding the existing
  SCSIPI_BUSTYPE_* (scsi, atapi, ata), and one for a per-SCSIPI_BUSTYPE_*
  subtype. Introduce macros to build or extract bustype_type.
- for SCSIPI_BUSTYPE_SCSI, define subtypes for parallel SCSI, Fibre Channel,
  SAS and USB, to specify the transport method. SCSIPI_BUSTYPE_SCSI_PSCSI
  is 0 so that bustype_type value doesn't change for existing code
- for non-SCSIPI_BUSTYPE_SCSI busses there's no defined subtype yet,
  so the bustype_type value doesn't change.
- provide scsi_fc_bustype, scsi_sas_bustype and scsi_usb_bustype
  along with scsi_bustype to be used by bus driver where appropriate
- scsipi_print_xfer_mode(): more existing code under a
  (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_PSCSI) case, as
  sync/wide parameters only make sense for parallel SCSI.
  For (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_FC) and
  (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_SAS), only print
  tagged queing status if enabled. Just be silent for other
  bustypes.

This change is prompted by this problem:
right now, FC (e.g. isp(4)) and SAS (e.g. mfi(4)) don't
  do anything for ADAPTER_REQ_SET_XFER_MODE, and especially never
  call scsipi_async_event(ASYNC_EVENT_XFER_MODE), so sd(4) always
  runs untagged. Doing a scsipi_async_event(ASYNC_EVENT_XFER_MODE) with
  appropriate parameters is enough to enable tagged queuing,
  but then scsipi will print:
  sd0: async, 8-bit transfers, tagged queueing
  which is harmless (async, 8-bit transfers doens't make sense on SAS anyway)
  but will confuse users. With this change scsipi will only print:
  sd0: tagged queueing
  which is correct.

In the long run, knowning the underlying transport in scsipi will
allow better handling of device which are not parallel SCSI.

Another change adding an extra callback to struct scsipi_bustype {}
will come (so that scsipi_print_xfer_mode(), which is SCSI-specific,
can be moved out of scsipi_base, and split into per-subtype callback),
but this will break kernel ABI and so is not suitable for
netbsd-6, so will be commmited later. The above is enough to get
tagged queuing on FC and SAS in netbsd-6.

diffstat:

 sys/dev/scsipi/atapiconf.c    |   7 +-
 sys/dev/scsipi/cd.c           |  10 ++--
 sys/dev/scsipi/scsiconf.c     |  33 +++++++++++++-
 sys/dev/scsipi/scsiconf.h     |   5 +-
 sys/dev/scsipi/scsipi_base.c  |  91 ++++++++++++++++++++++++++----------------
 sys/dev/scsipi/scsipi_ioctl.c |   8 +-
 sys/dev/scsipi/scsipiconf.h   |  19 ++++++++-
 sys/dev/scsipi/sd.c           |  10 ++--
 sys/dev/scsipi/st.c           |  10 ++-
 sys/dev/scsipi/st_atapi.c     |   7 +-
 sys/dev/scsipi/st_scsi.c      |   7 +-
 sys/dev/usb/umass_scsipi.c    |   7 +-
 12 files changed, 142 insertions(+), 72 deletions(-)

diffs (truncated from 493 to 300 lines):

diff -r 13006ff5e826 -r 6c2508e8a17d sys/dev/scsipi/atapiconf.c
--- a/sys/dev/scsipi/atapiconf.c        Thu Apr 19 17:28:25 2012 +0000
+++ b/sys/dev/scsipi/atapiconf.c        Thu Apr 19 17:45:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atapiconf.c,v 1.84 2012/04/06 17:12:45 chs Exp $       */
+/*     $NetBSD: atapiconf.c,v 1.85 2012/04/19 17:45:20 bouyer Exp $    */
 
 /*
  * Copyright (c) 1996, 2001 Manuel Bouyer.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.84 2012/04/06 17:12:45 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.85 2012/04/19 17:45:20 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -117,7 +117,8 @@
        if (chan == NULL)
                return (0);
 
-       if (chan->chan_bustype->bustype_type != SCSIPI_BUSTYPE_ATAPI)
+       if (SCSIPI_BUSTYPE_TYPE(chan->chan_bustype->bustype_type) !=
+           SCSIPI_BUSTYPE_ATAPI)
                return (0);
 
        return (1);
diff -r 13006ff5e826 -r 6c2508e8a17d sys/dev/scsipi/cd.c
--- a/sys/dev/scsipi/cd.c       Thu Apr 19 17:28:25 2012 +0000
+++ b/sys/dev/scsipi/cd.c       Thu Apr 19 17:45:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd.c,v 1.306 2012/02/25 10:17:14 shattered Exp $       */
+/*     $NetBSD: cd.c,v 1.307 2012/04/19 17:45:20 bouyer Exp $  */
 
 /*-
  * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation,
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.306 2012/02/25 10:17:14 shattered Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.307 2012/04/19 17:45:20 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -251,8 +251,8 @@
 
        mutex_init(&cd->sc_lock, MUTEX_DEFAULT, IPL_NONE);
 
-       if (scsipi_periph_bustype(sa->sa_periph) == SCSIPI_BUSTYPE_SCSI &&
-           periph->periph_version == 0)
+       if (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(sa->sa_periph)) ==
+           SCSIPI_BUSTYPE_SCSI && periph->periph_version == 0)
                cd->flags |= CDF_ANCIENT;
 
        bufq_alloc(&cd->buf_queue, "disksort", BUFQ_SORT_RAWBLOCK);
@@ -1682,7 +1682,7 @@
        lp->d_ncylinders = (cd->params.disksize / 100) + 1;
        lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
 
-       switch (scsipi_periph_bustype(cd->sc_periph)) {
+       switch (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(cd->sc_periph))) {
        case SCSIPI_BUSTYPE_SCSI:
                lp->d_type = DTYPE_SCSI;
                break;
diff -r 13006ff5e826 -r 6c2508e8a17d sys/dev/scsipi/scsiconf.c
--- a/sys/dev/scsipi/scsiconf.c Thu Apr 19 17:28:25 2012 +0000
+++ b/sys/dev/scsipi/scsiconf.c Thu Apr 19 17:45:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scsiconf.c,v 1.265 2012/04/06 22:50:39 christos Exp $  */
+/*     $NetBSD: scsiconf.c,v 1.266 2012/04/19 17:45:20 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.265 2012/04/06 22:50:39 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.266 2012/04/19 17:45:20 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -114,7 +114,31 @@
 static void    scsibus_config(struct scsipi_channel *, void *);
 
 const struct scsipi_bustype scsi_bustype = {
-       SCSIPI_BUSTYPE_SCSI,
+       SCSIPI_BUSTYPE_BUSTYPE(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_PSCSI),
+       scsi_scsipi_cmd,
+       scsipi_interpret_sense,
+       scsi_print_addr,
+       scsi_kill_pending,
+};
+
+const struct scsipi_bustype scsi_fc_bustype = {
+       SCSIPI_BUSTYPE_BUSTYPE(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_FC),
+       scsi_scsipi_cmd,
+       scsipi_interpret_sense,
+       scsi_print_addr,
+       scsi_kill_pending,
+};
+
+const struct scsipi_bustype scsi_sas_bustype = {
+       SCSIPI_BUSTYPE_BUSTYPE(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_SAS),
+       scsi_scsipi_cmd,
+       scsipi_interpret_sense,
+       scsi_print_addr,
+       scsi_kill_pending,
+};
+
+const struct scsipi_bustype scsi_usb_bustype = {
+       SCSIPI_BUSTYPE_BUSTYPE(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_USB),
        scsi_scsipi_cmd,
        scsipi_interpret_sense,
        scsi_print_addr,
@@ -153,7 +177,8 @@
 {
        struct scsipi_channel *chan = aux;
 
-       if (chan->chan_bustype->bustype_type != SCSIPI_BUSTYPE_SCSI)
+       if (SCSIPI_BUSTYPE_TYPE(chan->chan_bustype->bustype_type) !=
+           SCSIPI_BUSTYPE_SCSI)
                return 0;
 
        if (cf->cf_loc[SCSICF_CHANNEL] != chan->chan_channel &&
diff -r 13006ff5e826 -r 6c2508e8a17d sys/dev/scsipi/scsiconf.h
--- a/sys/dev/scsipi/scsiconf.h Thu Apr 19 17:28:25 2012 +0000
+++ b/sys/dev/scsipi/scsiconf.h Thu Apr 19 17:45:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scsiconf.h,v 1.56 2008/07/16 18:50:58 drochner Exp $   */
+/*     $NetBSD: scsiconf.h,v 1.57 2012/04/19 17:45:20 bouyer Exp $     */
 
 /*-
  * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
@@ -64,6 +64,9 @@
 #define        SCSIBUSF_OPEN   0x00000001      /* bus is open */
 
 extern const struct scsipi_bustype scsi_bustype;
+extern const struct scsipi_bustype scsi_fc_bustype;
+extern const struct scsipi_bustype scsi_sas_bustype;
+extern const struct scsipi_bustype scsi_usb_bustype;
 
 int    scsi_change_def(struct scsipi_periph *, int);
 void   scsi_kill_pending(struct scsipi_periph *);
diff -r 13006ff5e826 -r 6c2508e8a17d sys/dev/scsipi/scsipi_base.c
--- a/sys/dev/scsipi/scsipi_base.c      Thu Apr 19 17:28:25 2012 +0000
+++ b/sys/dev/scsipi/scsipi_base.c      Thu Apr 19 17:45:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scsipi_base.c,v 1.157 2012/04/18 20:37:49 bouyer Exp $ */
+/*     $NetBSD: scsipi_base.c,v 1.158 2012/04/19 17:45:20 bouyer Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.157 2012/04/18 20:37:49 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.158 2012/04/19 17:45:20 bouyer Exp $");
 
 #include "opt_scsi.h"
 
@@ -2181,42 +2181,63 @@
        if ((periph->periph_flags & PERIPH_MODE_VALID) == 0)
                return;
 
-       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");
+       switch(scsipi_periph_bustype(periph)) {
+       case SCSIPI_BUSTYPE_BUSTYPE(
+           SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_PSCSI):
+               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_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);
+               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");
+               break;
+       case SCSIPI_BUSTYPE_BUSTYPE(
+           SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_FC):
+       case SCSIPI_BUSTYPE_BUSTYPE(
+           SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_SAS):
+               if (periph->periph_mode & PERIPH_CAP_TQING) {
+                       aprint_normal_dev(periph->periph_dev,
+                           "tagged queueing\n");
+               }
+               break;
+       default:
+               /* nothing */
+               break;
        }
-
-       aprint_normal(" transfers");
-
-       if (periph->periph_mode & PERIPH_CAP_TQING)
-               aprint_normal(", tagged queueing");
-
-       aprint_normal("\n");
 }
 
 /*
diff -r 13006ff5e826 -r 6c2508e8a17d sys/dev/scsipi/scsipi_ioctl.c
--- a/sys/dev/scsipi/scsipi_ioctl.c     Thu Apr 19 17:28:25 2012 +0000
+++ b/sys/dev/scsipi/scsipi_ioctl.c     Thu Apr 19 17:45:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scsipi_ioctl.c,v 1.66 2008/07/14 12:36:44 drochner Exp $       */
+/*     $NetBSD: scsipi_ioctl.c,v 1.67 2012/04/19 17:45:20 bouyer Exp $ */
 
 /*-
  * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsipi_ioctl.c,v 1.66 2008/07/14 12:36:44 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsipi_ioctl.c,v 1.67 2012/04/19 17:45:20 bouyer Exp $");
 
 #include "opt_compat_freebsd.h"
 #include "opt_compat_netbsd.h"
@@ -379,7 +379,7 @@
        case SCIOCIDENTIFY: {
                struct scsi_addr *sca = (struct scsi_addr *)addr;
 
-               switch (scsipi_periph_bustype(periph)) {
+               switch (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(periph))) {
                case SCSIPI_BUSTYPE_SCSI:
                        sca->type = TYPE_SCSI;
                        sca->addr.scsi.scbus =
@@ -401,7 +401,7 @@
        case OSCIOCIDENTIFY: {
                struct oscsi_addr *sca = (struct oscsi_addr *)addr;
 
-               switch (scsipi_periph_bustype(periph)) {
+               switch (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(periph))) {
                case SCSIPI_BUSTYPE_SCSI:
                        sca->scbus =
                            device_unit(device_parent(periph->periph_dev));
diff -r 13006ff5e826 -r 6c2508e8a17d sys/dev/scsipi/scsipiconf.h
--- a/sys/dev/scsipi/scsipiconf.h       Thu Apr 19 17:28:25 2012 +0000
+++ b/sys/dev/scsipi/scsipiconf.h       Thu Apr 19 17:45:20 2012 +0000



Home | Main Index | Thread Index | Old Index