xref: /freebsd/sys/dev/aac/aac_debug.c (revision 685dc743)
135863739SMike Smith /*-
24d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni  *
435863739SMike Smith  * Copyright (c) 2000 Michael Smith
5c6eafcf2SScott Long  * Copyright (c) 2001 Scott Long
635863739SMike Smith  * Copyright (c) 2000 BSDi
7c6eafcf2SScott Long  * Copyright (c) 2001 Adaptec, Inc.
835863739SMike Smith  * All rights reserved.
935863739SMike Smith  *
1035863739SMike Smith  * Redistribution and use in source and binary forms, with or without
1135863739SMike Smith  * modification, are permitted provided that the following conditions
1235863739SMike Smith  * are met:
1335863739SMike Smith  * 1. Redistributions of source code must retain the above copyright
1435863739SMike Smith  *    notice, this list of conditions and the following disclaimer.
1535863739SMike Smith  * 2. Redistributions in binary form must reproduce the above copyright
1635863739SMike Smith  *    notice, this list of conditions and the following disclaimer in the
1735863739SMike Smith  *    documentation and/or other materials provided with the distribution.
1835863739SMike Smith  *
1935863739SMike Smith  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2035863739SMike Smith  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2135863739SMike Smith  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2235863739SMike Smith  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2335863739SMike Smith  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2435863739SMike Smith  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2535863739SMike Smith  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2635863739SMike Smith  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2735863739SMike Smith  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2835863739SMike Smith  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2935863739SMike Smith  * SUCH DAMAGE.
3035863739SMike Smith  */
3135863739SMike Smith 
32aad970f1SDavid E. O'Brien #include <sys/cdefs.h>
3335863739SMike Smith /*
3435863739SMike Smith  * Debugging support.
3535863739SMike Smith  */
36f6c4dd3fSScott Long #include "opt_aac.h"
3735863739SMike Smith 
3835863739SMike Smith #include <sys/param.h>
3935863739SMike Smith #include <sys/systm.h>
4035863739SMike Smith #include <sys/kernel.h>
41a4d7a3c0SPoul-Henning Kamp #include <sys/conf.h>
4235863739SMike Smith 
4335863739SMike Smith #include <sys/bus.h>
4435863739SMike Smith 
4535863739SMike Smith #include <machine/resource.h>
4635863739SMike Smith #include <machine/bus.h>
4735863739SMike Smith 
4835863739SMike Smith #include <dev/aac/aacreg.h>
490b0594cdSScott Long #include <sys/aac_ioctl.h>
5035863739SMike Smith #include <dev/aac/aacvar.h>
5135863739SMike Smith 
52da4c1ce3SJustin T. Gibbs #ifdef AAC_DEBUG
5331a0399eSEd Maste int	aac_debug_enable = 0;
5435863739SMike Smith void	aac_printstate0(void);
5535863739SMike Smith 
56914da7d0SScott Long /*
5735863739SMike Smith  * Dump the command queue indices
5835863739SMike Smith  */
5935863739SMike Smith void
aac_print_queues(struct aac_softc * sc)6035863739SMike Smith aac_print_queues(struct aac_softc *sc)
6135863739SMike Smith {
6235863739SMike Smith 	device_printf(sc->aac_dev, "FIB queue header at %p  queues at %p\n",
6335863739SMike Smith 	    &sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][0],
6435863739SMike Smith 	    &sc->aac_queues->qt_HostNormCmdQueue[0]);
6535863739SMike Smith 	device_printf(sc->aac_dev, "HOST_NORM_CMD  %d/%d (%d)\n",
66914da7d0SScott Long 	    sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][
67914da7d0SScott Long 				      AAC_PRODUCER_INDEX],
68914da7d0SScott Long 	    sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][
69914da7d0SScott Long 				      AAC_CONSUMER_INDEX],
7035863739SMike Smith 	    AAC_HOST_NORM_CMD_ENTRIES);
7135863739SMike Smith 	device_printf(sc->aac_dev, "HOST_HIGH_CMD  %d/%d (%d)\n",
72914da7d0SScott Long 	    sc->aac_queues->qt_qindex[AAC_HOST_HIGH_CMD_QUEUE][
73914da7d0SScott Long 				      AAC_PRODUCER_INDEX],
74914da7d0SScott Long 	    sc->aac_queues->qt_qindex[AAC_HOST_HIGH_CMD_QUEUE][
75914da7d0SScott Long 				      AAC_CONSUMER_INDEX],
7635863739SMike Smith 	    AAC_HOST_HIGH_CMD_ENTRIES);
7735863739SMike Smith 	device_printf(sc->aac_dev, "ADAP_NORM_CMD  %d/%d (%d)\n",
78914da7d0SScott Long 	    sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][
79914da7d0SScott Long 				      AAC_PRODUCER_INDEX],
80914da7d0SScott Long 	    sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][
81914da7d0SScott Long 				      AAC_CONSUMER_INDEX],
8235863739SMike Smith 	    AAC_ADAP_NORM_CMD_ENTRIES);
8335863739SMike Smith 	device_printf(sc->aac_dev, "ADAP_HIGH_CMD  %d/%d (%d)\n",
84914da7d0SScott Long 	    sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_CMD_QUEUE][
85914da7d0SScott Long 				      AAC_PRODUCER_INDEX],
86914da7d0SScott Long 	    sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_CMD_QUEUE][
87914da7d0SScott Long 				      AAC_CONSUMER_INDEX],
8835863739SMike Smith 	    AAC_ADAP_HIGH_CMD_ENTRIES);
8935863739SMike Smith 	device_printf(sc->aac_dev, "HOST_NORM_RESP %d/%d (%d)\n",
90914da7d0SScott Long 	    sc->aac_queues->qt_qindex[AAC_HOST_NORM_RESP_QUEUE][
91914da7d0SScott Long 				      AAC_PRODUCER_INDEX],
92914da7d0SScott Long 	    sc->aac_queues->qt_qindex[AAC_HOST_NORM_RESP_QUEUE][
93914da7d0SScott Long 				      AAC_CONSUMER_INDEX],
9435863739SMike Smith 	    AAC_HOST_NORM_RESP_ENTRIES);
9535863739SMike Smith 	device_printf(sc->aac_dev, "HOST_HIGH_RESP %d/%d (%d)\n",
96914da7d0SScott Long 	    sc->aac_queues->qt_qindex[AAC_HOST_HIGH_RESP_QUEUE][
97914da7d0SScott Long 				      AAC_PRODUCER_INDEX],
98914da7d0SScott Long 	    sc->aac_queues->qt_qindex[AAC_HOST_HIGH_RESP_QUEUE][
99914da7d0SScott Long 				      AAC_CONSUMER_INDEX],
10035863739SMike Smith 	    AAC_HOST_HIGH_RESP_ENTRIES);
10135863739SMike Smith 	device_printf(sc->aac_dev, "ADAP_NORM_RESP %d/%d (%d)\n",
102914da7d0SScott Long 	    sc->aac_queues->qt_qindex[AAC_ADAP_NORM_RESP_QUEUE][
103914da7d0SScott Long 				      AAC_PRODUCER_INDEX],
104914da7d0SScott Long 	    sc->aac_queues->qt_qindex[AAC_ADAP_NORM_RESP_QUEUE][
105914da7d0SScott Long 				      AAC_CONSUMER_INDEX],
10635863739SMike Smith 	    AAC_ADAP_NORM_RESP_ENTRIES);
10735863739SMike Smith 	device_printf(sc->aac_dev, "ADAP_HIGH_RESP %d/%d (%d)\n",
108914da7d0SScott Long 	    sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_RESP_QUEUE][
109914da7d0SScott Long 				      AAC_PRODUCER_INDEX],
110914da7d0SScott Long 	    sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_RESP_QUEUE][
111914da7d0SScott Long 				      AAC_CONSUMER_INDEX],
11235863739SMike Smith 	    AAC_ADAP_HIGH_RESP_ENTRIES);
1130b94a66eSMike Smith 	device_printf(sc->aac_dev, "AACQ_FREE      %d/%d\n",
1140b94a66eSMike Smith 	    sc->aac_qstat[AACQ_FREE].q_length, sc->aac_qstat[AACQ_FREE].q_max);
1150b94a66eSMike Smith 	device_printf(sc->aac_dev, "AACQ_BIO       %d/%d\n",
1160b94a66eSMike Smith 	    sc->aac_qstat[AACQ_BIO].q_length, sc->aac_qstat[AACQ_BIO].q_max);
1170b94a66eSMike Smith 	device_printf(sc->aac_dev, "AACQ_READY     %d/%d\n",
118914da7d0SScott Long 	    sc->aac_qstat[AACQ_READY].q_length,
119914da7d0SScott Long 	    sc->aac_qstat[AACQ_READY].q_max);
1200b94a66eSMike Smith 	device_printf(sc->aac_dev, "AACQ_BUSY      %d/%d\n",
1210b94a66eSMike Smith 	    sc->aac_qstat[AACQ_BUSY].q_length, sc->aac_qstat[AACQ_BUSY].q_max);
12235863739SMike Smith }
12335863739SMike Smith 
124914da7d0SScott Long /*
12535863739SMike Smith  * Print the command queue states for controller 0 (callable from DDB)
12635863739SMike Smith  */
12735863739SMike Smith void
aac_printstate0(void)12835863739SMike Smith aac_printstate0(void)
12935863739SMike Smith {
130914da7d0SScott Long 	struct aac_softc *sc;
131914da7d0SScott Long 
132e45bef2aSMike Smith 	sc = devclass_get_softc(devclass_find("aac"), 0);
13335863739SMike Smith 
13435863739SMike Smith 	aac_print_queues(sc);
13535863739SMike Smith 	switch (sc->aac_hwif) {
13635863739SMike Smith 	case AAC_HWIF_I960RX:
137ff0991c4SAttilio Rao 	case AAC_HWIF_NARK:
138914da7d0SScott Long 		device_printf(sc->aac_dev, "IDBR 0x%08x  IIMR 0x%08x  "
139ff0991c4SAttilio Rao 		    "IISR 0x%08x\n", AAC_MEM0_GETREG4(sc, AAC_RX_IDBR),
140ff0991c4SAttilio Rao 		    AAC_MEM0_GETREG4(sc, AAC_RX_IIMR), AAC_MEM0_GETREG4(sc, AAC_RX_IISR));
141914da7d0SScott Long 		device_printf(sc->aac_dev, "ODBR 0x%08x  OIMR 0x%08x  "
142ff0991c4SAttilio Rao 		    "OISR 0x%08x\n", AAC_MEM0_GETREG4(sc, AAC_RX_ODBR),
143ff0991c4SAttilio Rao 		    AAC_MEM0_GETREG4(sc, AAC_RX_OIMR), AAC_MEM0_GETREG4(sc, AAC_RX_OISR));
144ff0991c4SAttilio Rao 		AAC_MEM0_SETREG4(sc, AAC_RX_OIMR, 0/*~(AAC_DB_COMMAND_READY |
145c6eafcf2SScott Long 			    AAC_DB_RESPONSE_READY | AAC_DB_PRINTF)*/);
146914da7d0SScott Long 		device_printf(sc->aac_dev, "ODBR 0x%08x  OIMR 0x%08x  "
147ff0991c4SAttilio Rao 		    "OISR 0x%08x\n", AAC_MEM0_GETREG4(sc, AAC_RX_ODBR),
148ff0991c4SAttilio Rao 		    AAC_MEM0_GETREG4(sc, AAC_RX_OIMR), AAC_MEM0_GETREG4(sc, AAC_RX_OISR));
14935863739SMike Smith 		break;
15035863739SMike Smith 	case AAC_HWIF_STRONGARM:
15135863739SMike Smith 		/* XXX implement */
1527d05a383SPeter Wemm 		break;
15335863739SMike Smith 	}
15435863739SMike Smith }
15535863739SMike Smith 
156914da7d0SScott Long /*
15735863739SMike Smith  * Panic in a slightly informative fashion
15835863739SMike Smith  */
15935863739SMike Smith void
aac_panic(struct aac_softc * sc,char * reason)16035863739SMike Smith aac_panic(struct aac_softc *sc, char *reason)
16135863739SMike Smith {
16235863739SMike Smith 	aac_print_queues(sc);
16336e335c1SRoman Divacky 	panic("%s", reason);
16435863739SMike Smith }
16535863739SMike Smith 
166914da7d0SScott Long /*
16735863739SMike Smith  * Print a FIB
16835863739SMike Smith  */
16935863739SMike Smith void
aac_print_fib(struct aac_softc * sc,struct aac_fib * fib,const char * caller)17070148712SPeter Wemm aac_print_fib(struct aac_softc *sc, struct aac_fib *fib, const char *caller)
17135863739SMike Smith {
172f30ac74cSScott Long 	if (fib == NULL) {
173f30ac74cSScott Long 		device_printf(sc->aac_dev,
174f30ac74cSScott Long 			      "aac_print_fib called with NULL fib\n");
175f30ac74cSScott Long 		return;
176f30ac74cSScott Long 	}
17735863739SMike Smith 	device_printf(sc->aac_dev, "%s: FIB @ %p\n", caller, fib);
178914da7d0SScott Long 	device_printf(sc->aac_dev, "  XferState %b\n", fib->Header.XferState,
179914da7d0SScott Long 		      "\20"
18035863739SMike Smith 		      "\1HOSTOWNED"
18135863739SMike Smith 		      "\2ADAPTEROWNED"
18235863739SMike Smith 		      "\3INITIALISED"
18335863739SMike Smith 		      "\4EMPTY"
18435863739SMike Smith 		      "\5FROMPOOL"
18535863739SMike Smith 		      "\6FROMHOST"
18635863739SMike Smith 		      "\7FROMADAP"
18735863739SMike Smith 		      "\10REXPECTED"
18835863739SMike Smith 		      "\11RNOTEXPECTED"
18935863739SMike Smith 		      "\12DONEADAP"
19035863739SMike Smith 		      "\13DONEHOST"
19135863739SMike Smith 		      "\14HIGH"
19235863739SMike Smith 		      "\15NORM"
19335863739SMike Smith 		      "\16ASYNC"
19435863739SMike Smith 		      "\17PAGEFILEIO"
19535863739SMike Smith 		      "\20SHUTDOWN"
19635863739SMike Smith 		      "\21LAZYWRITE"
19735863739SMike Smith 		      "\22ADAPMICROFIB"
19835863739SMike Smith 		      "\23BIOSFIB"
19935863739SMike Smith 		      "\24FAST_RESPONSE"
20035863739SMike Smith 		      "\25APIFIB\n");
20135863739SMike Smith 	device_printf(sc->aac_dev, "  Command       %d\n", fib->Header.Command);
202c6eafcf2SScott Long 	device_printf(sc->aac_dev, "  StructType    %d\n",
203c6eafcf2SScott Long 		      fib->Header.StructType);
20435863739SMike Smith 	device_printf(sc->aac_dev, "  Flags         0x%x\n", fib->Header.Flags);
20535863739SMike Smith 	device_printf(sc->aac_dev, "  Size          %d\n", fib->Header.Size);
206b3457b51SScott Long 	device_printf(sc->aac_dev, "  SenderSize    %d\n",
207c6eafcf2SScott Long 		      fib->Header.SenderSize);
208c6eafcf2SScott Long 	device_printf(sc->aac_dev, "  SenderAddress 0x%x\n",
209c6eafcf2SScott Long 		      fib->Header.SenderFibAddress);
210914da7d0SScott Long 	device_printf(sc->aac_dev, "  RcvrAddress   0x%x\n",
211c6eafcf2SScott Long 		      fib->Header.ReceiverFibAddress);
212c6eafcf2SScott Long 	device_printf(sc->aac_dev, "  SenderData    0x%x\n",
213c6eafcf2SScott Long 		      fib->Header.SenderData);
21435863739SMike Smith 	switch(fib->Header.Command) {
21535863739SMike Smith 	case ContainerCommand:
21635863739SMike Smith 	{
217914da7d0SScott Long 		struct aac_blockread *br;
218b3457b51SScott Long 		struct aac_blockwrite *bw;
219914da7d0SScott Long 		struct aac_sg_table *sg;
22035863739SMike Smith 		int i;
221914da7d0SScott Long 
222914da7d0SScott Long 		br = (struct aac_blockread*)fib->data;
223914da7d0SScott Long 		bw = (struct aac_blockwrite*)fib->data;
224914da7d0SScott Long 		sg = NULL;
225914da7d0SScott Long 
22635863739SMike Smith 		if (br->Command == VM_CtBlockRead) {
227914da7d0SScott Long 			device_printf(sc->aac_dev,
228914da7d0SScott Long 				      "  BlockRead: container %d  0x%x/%d\n",
229914da7d0SScott Long 				      br->ContainerId, br->BlockNumber,
230914da7d0SScott Long 				      br->ByteCount);
23135863739SMike Smith 			sg = &br->SgMap;
23235863739SMike Smith 		}
23335863739SMike Smith 		if (bw->Command == VM_CtBlockWrite) {
234914da7d0SScott Long 			device_printf(sc->aac_dev,
235914da7d0SScott Long 				      "  BlockWrite: container %d  0x%x/%d "
236914da7d0SScott Long 				      "(%s)\n", bw->ContainerId,
237914da7d0SScott Long 				      bw->BlockNumber, bw->ByteCount,
238914da7d0SScott Long 				      bw->Stable == CSTABLE ? "stable" :
239c6eafcf2SScott Long 				      "unstable");
24035863739SMike Smith 			sg = &bw->SgMap;
24135863739SMike Smith 		}
24235863739SMike Smith 		if (sg != NULL) {
243914da7d0SScott Long 			device_printf(sc->aac_dev,
244914da7d0SScott Long 				      "  %d s/g entries\n", sg->SgCount);
24535863739SMike Smith 			for (i = 0; i < sg->SgCount; i++)
246c6eafcf2SScott Long 				device_printf(sc->aac_dev, "  0x%08x/%d\n",
247c6eafcf2SScott Long 					      sg->SgEntry[i].SgAddress,
248c6eafcf2SScott Long 					      sg->SgEntry[i].SgByteCount);
24935863739SMike Smith 		}
25035863739SMike Smith 		break;
25135863739SMike Smith 	}
25235863739SMike Smith 	default:
25335863739SMike Smith 		device_printf(sc->aac_dev, "   %16D\n", fib->data, " ");
25435863739SMike Smith 		device_printf(sc->aac_dev, "   %16D\n", fib->data + 16, " ");
25535863739SMike Smith 		break;
25635863739SMike Smith 	}
25735863739SMike Smith }
25835863739SMike Smith 
259914da7d0SScott Long /*
26035863739SMike Smith  * Describe an AIF we have received.
26135863739SMike Smith  */
26235863739SMike Smith void
aac_print_aif(struct aac_softc * sc,struct aac_aif_command * aif)26335863739SMike Smith aac_print_aif(struct aac_softc *sc, struct aac_aif_command *aif)
26435863739SMike Smith {
26535863739SMike Smith 	switch(aif->command) {
26635863739SMike Smith 	case AifCmdEventNotify:
26735863739SMike Smith 		device_printf(sc->aac_dev, "EventNotify(%d)\n", aif->seqNumber);
26835863739SMike Smith 		switch(aif->data.EN.type) {
26935863739SMike Smith 		case AifEnGeneric:		/* Generic notification */
27035863739SMike Smith 			device_printf(sc->aac_dev, "(Generic) %.*s\n",
271c6eafcf2SScott Long 				  (int)sizeof(aif->data.EN.data.EG),
272c6eafcf2SScott Long 				  aif->data.EN.data.EG.text);
27335863739SMike Smith 			break;
27435863739SMike Smith 		case AifEnTaskComplete:		/* Task has completed */
27535863739SMike Smith 			device_printf(sc->aac_dev, "(TaskComplete)\n");
27635863739SMike Smith 			break;
277c6eafcf2SScott Long 		case AifEnConfigChange:		/* Adapter configuration change
278c6eafcf2SScott Long 						 * occurred */
27935863739SMike Smith 			device_printf(sc->aac_dev, "(ConfigChange)\n");
28035863739SMike Smith 			break;
281c6eafcf2SScott Long 		case AifEnContainerChange:	/* Adapter specific container
282c6eafcf2SScott Long 						 * configuration change */
283914da7d0SScott Long 			device_printf(sc->aac_dev, "(ContainerChange) "
284914da7d0SScott Long 				      "container %d,%d\n",
28535863739SMike Smith 				      aif->data.EN.data.ECC.container[0],
28635863739SMike Smith 				      aif->data.EN.data.ECC.container[1]);
28735863739SMike Smith 			break;
28835863739SMike Smith 		case AifEnDeviceFailure:	/* SCSI device failed */
289914da7d0SScott Long 			device_printf(sc->aac_dev, "(DeviceFailure) "
290914da7d0SScott Long 				      "handle %d\n",
291914da7d0SScott Long 				      aif->data.EN.data.EDF.deviceHandle);
29235863739SMike Smith 			break;
29335863739SMike Smith 		case AifEnMirrorFailover:	/* Mirror failover started */
294914da7d0SScott Long 			device_printf(sc->aac_dev, "(MirrorFailover) "
295914da7d0SScott Long 				      "container %d failed, "
296c6eafcf2SScott Long 				      "migrating from slice %d to %d\n",
29735863739SMike Smith 				      aif->data.EN.data.EMF.container,
29835863739SMike Smith 				      aif->data.EN.data.EMF.failedSlice,
29935863739SMike Smith 				      aif->data.EN.data.EMF.creatingSlice);
30035863739SMike Smith 			break;
301c6eafcf2SScott Long 		case AifEnContainerEvent:	/* Significant container
302c6eafcf2SScott Long 						 * event */
303914da7d0SScott Long 			device_printf(sc->aac_dev, "(ContainerEvent) "
304914da7d0SScott Long 				      "container %d event "
305c6eafcf2SScott Long 				      "%d\n", aif->data.EN.data.ECE.container,
306914da7d0SScott Long 				      aif->data.EN.data.ECE.eventType);
30735863739SMike Smith 			break;
30835863739SMike Smith 		case AifEnFileSystemChange:	/* File system changed */
30935863739SMike Smith 			device_printf(sc->aac_dev, "(FileSystemChange)\n");
31035863739SMike Smith 			break;
31135863739SMike Smith 		case AifEnConfigPause:		/* Container pause event */
31235863739SMike Smith 			device_printf(sc->aac_dev, "(ConfigPause)\n");
31335863739SMike Smith 			break;
31435863739SMike Smith 		case AifEnConfigResume:		/* Container resume event */
31535863739SMike Smith 			device_printf(sc->aac_dev, "(ConfigResume)\n");
31635863739SMike Smith 			break;
317c6eafcf2SScott Long 		case AifEnFailoverChange:	/* Failover space assignment
318c6eafcf2SScott Long 						 * changed */
31935863739SMike Smith 			device_printf(sc->aac_dev, "(FailoverChange)\n");
32035863739SMike Smith 			break;
32135863739SMike Smith 		case AifEnRAID5RebuildDone:	/* RAID5 rebuild finished */
32235863739SMike Smith 			device_printf(sc->aac_dev, "(RAID5RebuildDone)\n");
32335863739SMike Smith 			break;
32435863739SMike Smith 		case AifEnEnclosureManagement:	/* Enclosure management event */
325914da7d0SScott Long 			device_printf(sc->aac_dev, "(EnclosureManagement) "
326914da7d0SScott Long 				      "EMPID %d unit %d "
327c6eafcf2SScott Long 				      "event %d\n", aif->data.EN.data.EEE.empID,
32835863739SMike Smith 				      aif->data.EN.data.EEE.unitID,
32935863739SMike Smith 				      aif->data.EN.data.EEE.eventType);
33035863739SMike Smith 			break;
331c6eafcf2SScott Long 		case AifEnBatteryEvent:		/* Significant NV battery
332c6eafcf2SScott Long 						 * event */
333914da7d0SScott Long 			device_printf(sc->aac_dev, "(BatteryEvent) %d "
334914da7d0SScott Long 				      "(state was %d, is %d\n",
335914da7d0SScott Long 				      aif->data.EN.data.EBE.transition_type,
336914da7d0SScott Long 				      aif->data.EN.data.EBE.current_state,
337914da7d0SScott Long 				      aif->data.EN.data.EBE.prior_state);
33835863739SMike Smith 			break;
339c6eafcf2SScott Long 		case AifEnAddContainer:		/* A new container was
340c6eafcf2SScott Long 						 * created. */
34135863739SMike Smith 			device_printf(sc->aac_dev, "(AddContainer)\n");
34235863739SMike Smith 			break;
34335863739SMike Smith 		case AifEnDeleteContainer:	/* A container was deleted. */
34435863739SMike Smith 			device_printf(sc->aac_dev, "(DeleteContainer)\n");
34535863739SMike Smith 			break;
346c6eafcf2SScott Long 		case AifEnBatteryNeedsRecond:	/* The battery needs
347c6eafcf2SScott Long 						 * reconditioning */
34835863739SMike Smith 			device_printf(sc->aac_dev, "(BatteryNeedsRecond)\n");
34935863739SMike Smith 			break;
35035863739SMike Smith 		case AifEnClusterEvent:		/* Some cluster event */
35135863739SMike Smith 			device_printf(sc->aac_dev, "(ClusterEvent) event %d\n",
35235863739SMike Smith 				      aif->data.EN.data.ECLE.eventType);
35335863739SMike Smith 			break;
354453130d9SPedro F. Giffuni 		case AifEnDiskSetEvent:		/* A disk set event occurred. */
355914da7d0SScott Long 			device_printf(sc->aac_dev, "(DiskSetEvent) event %d "
35613709702SDavid E. O'Brien 				      "diskset %jd creator %jd\n",
357914da7d0SScott Long 				      aif->data.EN.data.EDS.eventType,
35813709702SDavid E. O'Brien 				      (intmax_t)aif->data.EN.data.EDS.DsNum,
35913709702SDavid E. O'Brien 				      (intmax_t)aif->data.EN.data.EDS.CreatorId);
36035863739SMike Smith 			break;
361c6eafcf2SScott Long 		case AifDenMorphComplete: 	/* A morph operation
362c6eafcf2SScott Long 						 * completed */
36335863739SMike Smith 			device_printf(sc->aac_dev, "(MorphComplete)\n");
36435863739SMike Smith 			break;
365c6eafcf2SScott Long 		case AifDenVolumeExtendComplete: /* A volume expand operation
366c6eafcf2SScott Long 						  * completed */
36735863739SMike Smith 			device_printf(sc->aac_dev, "(VolumeExtendComplete)\n");
36835863739SMike Smith 			break;
36935863739SMike Smith 		default:
37035863739SMike Smith 			device_printf(sc->aac_dev, "(%d)\n", aif->data.EN.type);
37135863739SMike Smith 			break;
37235863739SMike Smith 		}
37335863739SMike Smith 		break;
37435863739SMike Smith 	case AifCmdJobProgress:
37535863739SMike Smith 	{
37635863739SMike Smith 		char	*status;
37735863739SMike Smith 		switch(aif->data.PR[0].status) {
37835863739SMike Smith 		case AifJobStsSuccess:
37935863739SMike Smith 			status = "success"; break;
38035863739SMike Smith 		case AifJobStsFinished:
38135863739SMike Smith 			status = "finished"; break;
38235863739SMike Smith 		case AifJobStsAborted:
38335863739SMike Smith 			status = "aborted"; break;
38435863739SMike Smith 		case AifJobStsFailed:
38535863739SMike Smith 			status = "failed"; break;
38635863739SMike Smith 		case AifJobStsSuspended:
38735863739SMike Smith 			status = "suspended"; break;
38835863739SMike Smith 		case AifJobStsRunning:
38935863739SMike Smith 			status = "running"; break;
39035863739SMike Smith 		default:
39135863739SMike Smith 			status = "unknown status"; break;
39235863739SMike Smith 		}
39335863739SMike Smith 
394c6eafcf2SScott Long 		device_printf(sc->aac_dev, "JobProgress (%d) - %s (%d, %d)\n",
395914da7d0SScott Long 			      aif->seqNumber, status,
396914da7d0SScott Long 			      aif->data.PR[0].currentTick,
397c6eafcf2SScott Long 			      aif->data.PR[0].finalTick);
39835863739SMike Smith 		switch(aif->data.PR[0].jd.type) {
399c6eafcf2SScott Long 		case AifJobScsiZero:		/* SCSI dev clear operation */
400c6eafcf2SScott Long 			device_printf(sc->aac_dev, "(ScsiZero) handle %d\n",
401c6eafcf2SScott Long 				      aif->data.PR[0].jd.client.scsi_dh);
40235863739SMike Smith 			break;
403c6eafcf2SScott Long 		case AifJobScsiVerify:		/* SCSI device Verify operation
404c6eafcf2SScott Long 						 * NO REPAIR */
405c6eafcf2SScott Long 			device_printf(sc->aac_dev, "(ScsiVerify) handle %d\n",
406c6eafcf2SScott Long 				      aif->data.PR[0].jd.client.scsi_dh);
40735863739SMike Smith 			break;
408c6eafcf2SScott Long 		case AifJobScsiExercise:	/* SCSI device Exercise
409c6eafcf2SScott Long 						 * operation */
410c6eafcf2SScott Long 			device_printf(sc->aac_dev, "(ScsiExercise) handle %d\n",
411c6eafcf2SScott Long 				      aif->data.PR[0].jd.client.scsi_dh);
41235863739SMike Smith 			break;
413c6eafcf2SScott Long 		case AifJobScsiVerifyRepair:	/* SCSI device Verify operation
414c6eafcf2SScott Long 						 * WITH repair */
415914da7d0SScott Long 			device_printf(sc->aac_dev,
416914da7d0SScott Long 				      "(ScsiVerifyRepair) handle %d\n",
417c6eafcf2SScott Long 				      aif->data.PR[0].jd.client.scsi_dh);
41835863739SMike Smith 			break;
41935863739SMike Smith 		case AifJobCtrZero:		/* Container clear operation */
420914da7d0SScott Long 			device_printf(sc->aac_dev,
4213b6efc61SRobert Watson 				      "(ContainerZero) container %d\n",
42235863739SMike Smith 				      aif->data.PR[0].jd.client.container.src);
42335863739SMike Smith 			break;
42435863739SMike Smith 		case AifJobCtrCopy:		/* Container copy operation */
425914da7d0SScott Long 			device_printf(sc->aac_dev,
4263b6efc61SRobert Watson 				      "(ContainerCopy) container %d to %d\n",
427c6eafcf2SScott Long 				      aif->data.PR[0].jd.client.container.src,
428c6eafcf2SScott Long 				      aif->data.PR[0].jd.client.container.dst);
42935863739SMike Smith 			break;
430c6eafcf2SScott Long 		case AifJobCtrCreateMirror:	/* Container Create Mirror
431c6eafcf2SScott Long 						 * operation */
432914da7d0SScott Long 			device_printf(sc->aac_dev,
4333b6efc61SRobert Watson 				      "(ContainerCreateMirror) container %d\n",
434914da7d0SScott Long 				      aif->data.PR[0].jd.client.container.src);
435c6eafcf2SScott Long 				      /* XXX two containers? */
43635863739SMike Smith 			break;
437c6eafcf2SScott Long 		case AifJobCtrMergeMirror:	/* Container Merge Mirror
438c6eafcf2SScott Long 						 * operation */
439914da7d0SScott Long 			device_printf(sc->aac_dev,
4403b6efc61SRobert Watson 				      "(ContainerMergeMirror) container %d\n",
441c6eafcf2SScott Long 				      aif->data.PR[0].jd.client.container.src);
442c6eafcf2SScott Long 				      /* XXX two containers? */
44335863739SMike Smith 			break;
444c6eafcf2SScott Long 		case AifJobCtrScrubMirror:	/* Container Scrub Mirror
445c6eafcf2SScott Long 						 * operation */
446914da7d0SScott Long 			device_printf(sc->aac_dev,
4473b6efc61SRobert Watson 				      "(ContainerScrubMirror) container %d\n",
44835863739SMike Smith 				      aif->data.PR[0].jd.client.container.src);
44935863739SMike Smith 			break;
450c6eafcf2SScott Long 		case AifJobCtrRebuildRaid5:	/* Container Rebuild Raid5
451c6eafcf2SScott Long 						 * operation */
452914da7d0SScott Long 			device_printf(sc->aac_dev,
4533b6efc61SRobert Watson 				      "(ContainerRebuildRaid5) container %d\n",
454914da7d0SScott Long 				      aif->data.PR[0].jd.client.container.src);
45535863739SMike Smith 			break;
456c6eafcf2SScott Long 		case AifJobCtrScrubRaid5:	/* Container Scrub Raid5
457c6eafcf2SScott Long 						 * operation */
458914da7d0SScott Long 			device_printf(sc->aac_dev,
4593b6efc61SRobert Watson 				      "(ContainerScrubRaid5) container %d\n",
46035863739SMike Smith 				      aif->data.PR[0].jd.client.container.src);
46135863739SMike Smith 			break;
46235863739SMike Smith 		case AifJobCtrMorph:		/* Container morph operation */
463914da7d0SScott Long 			device_printf(sc->aac_dev,
4643b6efc61SRobert Watson 				      "(ContainerMorph) container %d\n",
46535863739SMike Smith 				      aif->data.PR[0].jd.client.container.src);
466c6eafcf2SScott Long 				      /* XXX two containers? */
467c6eafcf2SScott Long 			break;
468c6eafcf2SScott Long 		case AifJobCtrPartCopy:		/* Container Partition copy
469c6eafcf2SScott Long 						 * operation */
470914da7d0SScott Long 			device_printf(sc->aac_dev,
4713b6efc61SRobert Watson 				      "(ContainerPartCopy) container %d to "
472914da7d0SScott Long 				      "%d\n",
473914da7d0SScott Long 				      aif->data.PR[0].jd.client.container.src,
474c6eafcf2SScott Long 				      aif->data.PR[0].jd.client.container.dst);
475c6eafcf2SScott Long 			break;
476c6eafcf2SScott Long 		case AifJobCtrRebuildMirror:	/* Container Rebuild Mirror
477c6eafcf2SScott Long 						 * operation */
478914da7d0SScott Long 			device_printf(sc->aac_dev,
4793b6efc61SRobert Watson 				      "(ContainerRebuildMirror) container "
480914da7d0SScott Long 				      "%d\n",
481914da7d0SScott Long 				      aif->data.PR[0].jd.client.container.src);
48235863739SMike Smith 			break;
48335863739SMike Smith 		case AifJobCtrCrazyCache:	/* crazy cache */
484914da7d0SScott Long 			device_printf(sc->aac_dev,
4853b6efc61SRobert Watson 				      "(ContainerCrazyCache) container %d\n",
486c6eafcf2SScott Long 				      aif->data.PR[0].jd.client.container.src);
487c6eafcf2SScott Long 				      /* XXX two containers? */
48835863739SMike Smith 			break;
489c6eafcf2SScott Long 		case AifJobFsCreate:		/* File System Create
490c6eafcf2SScott Long 						 * operation */
49135863739SMike Smith 			device_printf(sc->aac_dev, "(FsCreate)\n");
49235863739SMike Smith 			break;
493c6eafcf2SScott Long 		case AifJobFsVerify:		/* File System Verify
494c6eafcf2SScott Long 						 * operation */
49535863739SMike Smith 			device_printf(sc->aac_dev, "(FsVerivy)\n");
49635863739SMike Smith 			break;
497c6eafcf2SScott Long 		case AifJobFsExtend:		/* File System Extend
498c6eafcf2SScott Long 						 * operation */
49935863739SMike Smith 			device_printf(sc->aac_dev, "(FsExtend)\n");
50035863739SMike Smith 			break;
50135863739SMike Smith 		case AifJobApiFormatNTFS:	/* Format a drive to NTFS */
50235863739SMike Smith 			device_printf(sc->aac_dev, "(FormatNTFS)\n");
50335863739SMike Smith 			break;
50435863739SMike Smith 		case AifJobApiFormatFAT:	/* Format a drive to FAT */
50535863739SMike Smith 			device_printf(sc->aac_dev, "(FormatFAT)\n");
50635863739SMike Smith 			break;
507c6eafcf2SScott Long 		case AifJobApiUpdateSnapshot:	/* update the read/write half
508c6eafcf2SScott Long 						 * of a snapshot */
50935863739SMike Smith 			device_printf(sc->aac_dev, "(UpdateSnapshot)\n");
51035863739SMike Smith 			break;
51135863739SMike Smith 		case AifJobApiFormatFAT32:	/* Format a drive to FAT32 */
51235863739SMike Smith 			device_printf(sc->aac_dev, "(FormatFAT32)\n");
51335863739SMike Smith 			break;
51435863739SMike Smith 		case AifJobCtlContinuousCtrVerify: /* Adapter operation */
51535863739SMike Smith 			device_printf(sc->aac_dev, "(ContinuousCtrVerify)\n");
51635863739SMike Smith 			break;
51735863739SMike Smith 		default:
518914da7d0SScott Long 			device_printf(sc->aac_dev, "(%d)\n",
519914da7d0SScott Long 				      aif->data.PR[0].jd.type);
52035863739SMike Smith 			break;
52135863739SMike Smith 		}
52235863739SMike Smith 		break;
52335863739SMike Smith 	}
52435863739SMike Smith 	case AifCmdAPIReport:
52535863739SMike Smith 		device_printf(sc->aac_dev, "APIReport (%d)\n", aif->seqNumber);
52635863739SMike Smith 		break;
52735863739SMike Smith 	case AifCmdDriverNotify:
528914da7d0SScott Long 		device_printf(sc->aac_dev, "DriverNotify (%d)\n",
529914da7d0SScott Long 			      aif->seqNumber);
53035863739SMike Smith 		break;
53135863739SMike Smith 	default:
532c6eafcf2SScott Long 		device_printf(sc->aac_dev, "AIF %d (%d)\n", aif->command,
533c6eafcf2SScott Long 			      aif->seqNumber);
53435863739SMike Smith 		break;
53535863739SMike Smith 	}
53635863739SMike Smith }
537f6c4dd3fSScott Long #endif /* AAC_DEBUG */
538