Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci - Record more information about the array unit, ...



details:   https://anonhg.NetBSD.org/src/rev/435a3c8c59a9
branches:  trunk
changeset: 552214:435a3c8c59a9
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Sep 21 19:20:18 2003 +0000

description:
- Record more information about the array unit, including array
  type and stripe depth.
- Report array type and stripe depth when attaching the logical drive.

diffstat:

 sys/dev/pci/ld_twe.c |  38 +++++++++++++++++++++++++++-----
 sys/dev/pci/twe.c    |  61 ++++++++++++++++++++++++++++++++++++++++++---------
 sys/dev/pci/twevar.h |  13 +++++++++-
 3 files changed, 93 insertions(+), 19 deletions(-)

diffs (226 lines):

diff -r a21e2b13600d -r 435a3c8c59a9 sys/dev/pci/ld_twe.c
--- a/sys/dev/pci/ld_twe.c      Sun Sep 21 19:16:48 2003 +0000
+++ b/sys/dev/pci/ld_twe.c      Sun Sep 21 19:20:18 2003 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: ld_twe.c,v 1.13 2002/10/02 16:51:43 thorpej Exp $      */
+/*     $NetBSD: ld_twe.c,v 1.14 2003/09/21 19:20:18 thorpej Exp $      */
 
 /*-
- * Copyright (c) 2000, 2001, 2002 The NetBSD Foundation, Inc.
+ * Copyright (c) 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
- * by Andrew Doran.
+ * by Andrew Doran; and by Jason R. Thorpe of Wasabi Systems, Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld_twe.c,v 1.13 2002/10/02 16:51:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_twe.c,v 1.14 2003/09/21 19:20:18 thorpej Exp $");
 
 #include "rnd.h"
 
@@ -96,22 +96,48 @@
        struct ld_twe_softc *sc;
        struct ld_softc *ld;
        struct twe_softc *twe;
+       struct twe_drive *td;
+       const char *typestr, *stripestr;
+       char unktype[16], stripebuf[32];
 
        sc = (struct ld_twe_softc *)self;
        ld = &sc->sc_ld;
        twe = (struct twe_softc *)parent;
        twea = aux;
+       td = &twe->sc_units[twea->twea_unit];
 
        sc->sc_hwunit = twea->twea_unit;
        ld->sc_flags = LDF_ENABLED;
        ld->sc_maxxfer = twe_get_maxxfer(twe_get_maxsegs());
-       ld->sc_secperunit = twe->sc_dsize[twea->twea_unit];
+       ld->sc_secperunit = td->td_size;
        ld->sc_secsize = TWE_SECTOR_SIZE;
        ld->sc_maxqueuecnt = (TWE_MAX_QUEUECNT - 1) / twe->sc_nunits;
        ld->sc_start = ld_twe_start;
        ld->sc_dump = ld_twe_dump;
 
-       printf("\n");
+       typestr = twe_describe_code(twe_table_unittype, td->td_type);
+       if (typestr == NULL) {
+               sprintf(unktype, "<0x%02x>", td->td_type);
+               typestr = unktype;
+       }
+       switch (td->td_type) {
+       case TWE_AD_CONFIG_RAID0:
+       /* XXX TWE_AD_CONFIG_TwinStor? */
+       case TWE_AD_CONFIG_RAID5:
+       case TWE_AD_CONFIG_RAID10:
+               stripestr = twe_describe_code(twe_table_stripedepth,
+                   td->td_stripe);
+               if (stripestr == NULL)
+                       sprintf(stripebuf, "<stripe code 0x%02x> ",
+                           td->td_stripe);
+               else
+                       sprintf(stripebuf, "%s stripe ", stripestr);
+               break;
+       default:
+               stripebuf[0] = '\0';
+       }
+
+       printf(": %s%s\n", stripebuf, typestr);
        ldattach(ld);
 }
 
diff -r a21e2b13600d -r 435a3c8c59a9 sys/dev/pci/twe.c
--- a/sys/dev/pci/twe.c Sun Sep 21 19:16:48 2003 +0000
+++ b/sys/dev/pci/twe.c Sun Sep 21 19:20:18 2003 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: twe.c,v 1.41 2003/09/21 19:01:05 thorpej Exp $ */
+/*     $NetBSD: twe.c,v 1.42 2003/09/21 19:20:18 thorpej Exp $ */
 
 /*-
- * Copyright (c) 2000, 2001, 2002 The NetBSD Foundation, Inc.
+ * Copyright (c) 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
- * by Andrew Doran.
+ * by Andrew Doran; and by Jason R. Thorpe of Wasabi Systems, Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: twe.c,v 1.41 2003/09/21 19:01:05 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: twe.c,v 1.42 2003/09/21 19:20:18 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -309,11 +309,14 @@
        const char *intrstr;
        int size, i, rv, rseg;
        size_t max_segs, max_xfer;
-       struct twe_param *dtp;
+       struct twe_param *dtp, *atp;
+       struct twe_array_descriptor *ad;
+       struct twe_drive *td;
        bus_dma_segment_t seg;
        struct twe_cmd *tc;
        struct twe_attach_args twea;
        struct twe_ccb *ccb;
+       uint16_t dsize;
 
        sc = (struct twe_softc *)self;
        pa = aux;
@@ -450,17 +453,51 @@
 
        /* For each detected unit, collect size and store in an array. */
        for (i = 0, sc->sc_nunits = 0; i < TWE_MAX_UNITS; i++) {
+               td = &sc->sc_units[i];
+
                /* Unit present? */
                if ((dtp->tp_data[i] & TWE_PARAM_UNITSTATUS_Online) == 0) {
-                       sc->sc_dsize[i] = 0;
+                       td->td_size = 0;
+                       td->td_type = 0;
+                       td->td_stripe = 0;
                        continue;
                }
 
-               rv = twe_param_get_4(sc, TWE_PARAM_UNITINFO + i,
-                   TWE_PARAM_UNITINFO_Capacity, &sc->sc_dsize[i]);
+               rv = twe_param_get_2(sc, TWE_PARAM_UNITINFO + i,
+                   TWE_PARAM_UNITINFO_DescriptorSize, &dsize);
+               if (rv != 0) {
+                       aprint_error("%s: error %d fetching descriptor size "
+                           "for unit %d\n", sc->sc_dv.dv_xname, rv, i);
+                       td->td_size = 0;
+                       td->td_type = 0;
+                       td->td_stripe = 0;
+                       continue;
+               }
+
+               rv = twe_param_get(sc, TWE_PARAM_UNITINFO + i,
+                   TWE_PARAM_UNITINFO_Descriptor, dsize - 3, NULL, &atp);
                if (rv != 0) {
-                       aprint_error("%s: error %d fetching capacity for unit %d\n",
+                       aprint_error("%s: error %d fetching array descriptor "
+                           "for unit %d\n", sc->sc_dv.dv_xname, rv, i);
+                       td->td_size = 0;
+                       td->td_type = 0;
+                       td->td_stripe = 0;
+                       continue;
+               }
+               ad = (struct twe_array_descriptor *)atp->tp_data;
+               td->td_type = ad->configuration;
+               td->td_stripe = ad->stripe_size;
+               free(atp, M_DEVBUF);
+
+               rv = twe_param_get_4(sc, TWE_PARAM_UNITINFO + i,
+                   TWE_PARAM_UNITINFO_Capacity, &td->td_size);
+               if (rv != 0) {
+                       aprint_error(
+                           "%s: error %d fetching capacity for unit %d\n",
                            sc->sc_dv.dv_xname, rv, i);
+                       td->td_size = 0;
+                       td->td_type = 0;
+                       td->td_stripe = 0;
                        continue;
                }
 
@@ -478,10 +515,12 @@
 
        /* Attach sub-devices. */
        for (i = 0; i < TWE_MAX_UNITS; i++) {
-               if (sc->sc_dsize[i] == 0)
+               td = &sc->sc_units[i];
+               if (td->td_size == 0)
                        continue;
                twea.twea_unit = i;
-               config_found_sm(&sc->sc_dv, &twea, twe_print, twe_submatch);
+               td->td_dev = config_found_sm(&sc->sc_dv, &twea, twe_print,
+                   twe_submatch);
        }
 }
 
diff -r a21e2b13600d -r 435a3c8c59a9 sys/dev/pci/twevar.h
--- a/sys/dev/pci/twevar.h      Sun Sep 21 19:16:48 2003 +0000
+++ b/sys/dev/pci/twevar.h      Sun Sep 21 19:20:18 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: twevar.h,v 1.14 2003/09/21 18:35:32 thorpej Exp $      */
+/*     $NetBSD: twevar.h,v 1.15 2003/09/21 19:20:19 thorpej Exp $      */
 
 /*-
  * Copyright (c) 2000, 2001, 2002 The NetBSD Foundation, Inc.
@@ -43,6 +43,15 @@
 
 #define        TWE_MAX_QUEUECNT        129
 
+/* Per-array drive information. */
+struct twe_drive {
+       uint32_t                td_size;
+       uint8_t                 td_type;
+       uint8_t                 td_stripe;
+
+       struct device           *td_dev;
+};
+
 /* Per-controller state. */
 struct twe_softc {
        struct device           sc_dv;
@@ -59,7 +68,7 @@
        SLIST_HEAD(, twe_ccb)   sc_ccb_freelist;
        int                     sc_flags;
        int                     sc_nunits;
-       u_int                   sc_dsize[TWE_MAX_UNITS];
+       struct twe_drive        sc_units[TWE_MAX_UNITS];
 };
 #define        TWEF_AEN        0x01    /* retrieving an AEN */
 #define        TWEF_OPEN       0x02    /* control device is opened */



Home | Main Index | Thread Index | Old Index