2 * Copyright (c) 2000 Michael Smith
3 * Copyright (c) 2001 Scott Long
4 * Copyright (c) 2000 BSDi
5 * Copyright (c) 2001 Adaptec, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * $FreeBSD: src/sys/dev/aac/aac_debug.c,v 1.2.2.5 2003/01/11 18:39:39 scottl Exp $
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/kernel.h>
41 #include <dev/aac/aac_compat.h>
43 #include <sys/devicestat.h>
46 #include <machine/resource.h>
47 #include <machine/bus.h>
49 #include <dev/aac/aacreg.h>
50 #include <dev/aac/aac_ioctl.h>
51 #include <dev/aac/aacvar.h>
54 void aac_printstate0(void);
58 * Dump the command queue indices
61 aac_print_queues(struct aac_softc *sc)
63 device_printf(sc->aac_dev, "FIB queue header at %p queues at %p\n",
64 &sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][0],
65 &sc->aac_queues->qt_HostNormCmdQueue[0]);
66 device_printf(sc->aac_dev, "HOST_NORM_CMD %d/%d (%d)\n",
67 sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][
69 sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][
71 AAC_HOST_NORM_CMD_ENTRIES);
72 device_printf(sc->aac_dev, "HOST_HIGH_CMD %d/%d (%d)\n",
73 sc->aac_queues->qt_qindex[AAC_HOST_HIGH_CMD_QUEUE][
75 sc->aac_queues->qt_qindex[AAC_HOST_HIGH_CMD_QUEUE][
77 AAC_HOST_HIGH_CMD_ENTRIES);
78 device_printf(sc->aac_dev, "ADAP_NORM_CMD %d/%d (%d)\n",
79 sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][
81 sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][
83 AAC_ADAP_NORM_CMD_ENTRIES);
84 device_printf(sc->aac_dev, "ADAP_HIGH_CMD %d/%d (%d)\n",
85 sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_CMD_QUEUE][
87 sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_CMD_QUEUE][
89 AAC_ADAP_HIGH_CMD_ENTRIES);
90 device_printf(sc->aac_dev, "HOST_NORM_RESP %d/%d (%d)\n",
91 sc->aac_queues->qt_qindex[AAC_HOST_NORM_RESP_QUEUE][
93 sc->aac_queues->qt_qindex[AAC_HOST_NORM_RESP_QUEUE][
95 AAC_HOST_NORM_RESP_ENTRIES);
96 device_printf(sc->aac_dev, "HOST_HIGH_RESP %d/%d (%d)\n",
97 sc->aac_queues->qt_qindex[AAC_HOST_HIGH_RESP_QUEUE][
99 sc->aac_queues->qt_qindex[AAC_HOST_HIGH_RESP_QUEUE][
101 AAC_HOST_HIGH_RESP_ENTRIES);
102 device_printf(sc->aac_dev, "ADAP_NORM_RESP %d/%d (%d)\n",
103 sc->aac_queues->qt_qindex[AAC_ADAP_NORM_RESP_QUEUE][
105 sc->aac_queues->qt_qindex[AAC_ADAP_NORM_RESP_QUEUE][
107 AAC_ADAP_NORM_RESP_ENTRIES);
108 device_printf(sc->aac_dev, "ADAP_HIGH_RESP %d/%d (%d)\n",
109 sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_RESP_QUEUE][
111 sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_RESP_QUEUE][
113 AAC_ADAP_HIGH_RESP_ENTRIES);
114 device_printf(sc->aac_dev, "AACQ_FREE %d/%d\n",
115 sc->aac_qstat[AACQ_FREE].q_length, sc->aac_qstat[AACQ_FREE].q_max);
116 device_printf(sc->aac_dev, "AACQ_BIO %d/%d\n",
117 sc->aac_qstat[AACQ_BIO].q_length, sc->aac_qstat[AACQ_BIO].q_max);
118 device_printf(sc->aac_dev, "AACQ_READY %d/%d\n",
119 sc->aac_qstat[AACQ_READY].q_length,
120 sc->aac_qstat[AACQ_READY].q_max);
121 device_printf(sc->aac_dev, "AACQ_BUSY %d/%d\n",
122 sc->aac_qstat[AACQ_BUSY].q_length, sc->aac_qstat[AACQ_BUSY].q_max);
123 device_printf(sc->aac_dev, "AACQ_COMPLETE %d/%d\n",
124 sc->aac_qstat[AACQ_COMPLETE].q_length,
125 sc->aac_qstat[AACQ_COMPLETE].q_max);
129 * Print the command queue states for controller 0 (callable from DDB)
132 aac_printstate0(void)
134 struct aac_softc *sc;
136 sc = devclass_get_softc(aac_devclass, 0);
138 aac_print_queues(sc);
139 switch (sc->aac_hwif) {
140 case AAC_HWIF_I960RX:
141 device_printf(sc->aac_dev, "IDBR 0x%08x IIMR 0x%08x "
142 "IISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_IDBR),
143 AAC_GETREG4(sc, AAC_RX_IIMR), AAC_GETREG4(sc, AAC_RX_IISR));
144 device_printf(sc->aac_dev, "ODBR 0x%08x OIMR 0x%08x "
145 "OISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_ODBR),
146 AAC_GETREG4(sc, AAC_RX_OIMR), AAC_GETREG4(sc, AAC_RX_OISR));
147 AAC_SETREG4(sc, AAC_RX_OIMR, 0/*~(AAC_DB_COMMAND_READY |
148 AAC_DB_RESPONSE_READY | AAC_DB_PRINTF)*/);
149 device_printf(sc->aac_dev, "ODBR 0x%08x OIMR 0x%08x "
150 "OISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_ODBR),
151 AAC_GETREG4(sc, AAC_RX_OIMR), AAC_GETREG4(sc, AAC_RX_OISR));
153 case AAC_HWIF_STRONGARM:
159 * simulate an interrupt for controller 0
164 struct aac_softc *sc;
166 sc = devclass_get_softc(aac_devclass, 0);
172 * Panic in a slightly informative fashion
175 aac_panic(struct aac_softc *sc, char *reason)
177 aac_print_queues(sc);
185 aac_print_fib(struct aac_softc *sc, struct aac_fib *fib, char *caller)
188 device_printf(sc->aac_dev,
189 "aac_print_fib called with NULL fib\n");
192 device_printf(sc->aac_dev, "%s: FIB @ %p\n", caller, fib);
193 device_printf(sc->aac_dev, " XferState %b\n", fib->Header.XferState,
216 device_printf(sc->aac_dev, " Command %d\n", fib->Header.Command);
217 device_printf(sc->aac_dev, " StructType %d\n",
218 fib->Header.StructType);
219 device_printf(sc->aac_dev, " Flags 0x%x\n", fib->Header.Flags);
220 device_printf(sc->aac_dev, " Size %d\n", fib->Header.Size);
221 device_printf(sc->aac_dev, " SenderSize %d\n",
222 fib->Header.SenderSize);
223 device_printf(sc->aac_dev, " SenderAddress 0x%x\n",
224 fib->Header.SenderFibAddress);
225 device_printf(sc->aac_dev, " RcvrAddress 0x%x\n",
226 fib->Header.ReceiverFibAddress);
227 device_printf(sc->aac_dev, " SenderData 0x%x\n",
228 fib->Header.SenderData);
229 switch(fib->Header.Command) {
230 case ContainerCommand:
232 struct aac_blockread *br;
233 struct aac_blockwrite *bw;
234 struct aac_sg_table *sg;
237 br = (struct aac_blockread*)fib->data;
238 bw = (struct aac_blockwrite*)fib->data;
241 if (br->Command == VM_CtBlockRead) {
242 device_printf(sc->aac_dev,
243 " BlockRead: container %d 0x%x/%d\n",
244 br->ContainerId, br->BlockNumber,
248 if (bw->Command == VM_CtBlockWrite) {
249 device_printf(sc->aac_dev,
250 " BlockWrite: container %d 0x%x/%d "
251 "(%s)\n", bw->ContainerId,
252 bw->BlockNumber, bw->ByteCount,
253 bw->Stable == CSTABLE ? "stable" :
258 device_printf(sc->aac_dev,
259 " %d s/g entries\n", sg->SgCount);
260 for (i = 0; i < sg->SgCount; i++)
261 device_printf(sc->aac_dev, " 0x%08x/%d\n",
262 sg->SgEntry[i].SgAddress,
263 sg->SgEntry[i].SgByteCount);
268 device_printf(sc->aac_dev, " %16D\n", fib->data, " ");
269 device_printf(sc->aac_dev, " %16D\n", fib->data + 16, " ");
275 * Describe an AIF we have received.
278 aac_print_aif(struct aac_softc *sc, struct aac_aif_command *aif)
280 switch(aif->command) {
281 case AifCmdEventNotify:
282 device_printf(sc->aac_dev, "EventNotify(%d)\n", aif->seqNumber);
283 switch(aif->data.EN.type) {
284 case AifEnGeneric: /* Generic notification */
285 device_printf(sc->aac_dev, "(Generic) %.*s\n",
286 (int)sizeof(aif->data.EN.data.EG),
287 aif->data.EN.data.EG.text);
289 case AifEnTaskComplete: /* Task has completed */
290 device_printf(sc->aac_dev, "(TaskComplete)\n");
292 case AifEnConfigChange: /* Adapter configuration change
294 device_printf(sc->aac_dev, "(ConfigChange)\n");
296 case AifEnContainerChange: /* Adapter specific container
297 * configuration change */
298 device_printf(sc->aac_dev, "(ContainerChange) "
300 aif->data.EN.data.ECC.container[0],
301 aif->data.EN.data.ECC.container[1]);
303 case AifEnDeviceFailure: /* SCSI device failed */
304 device_printf(sc->aac_dev, "(DeviceFailure) "
306 aif->data.EN.data.EDF.deviceHandle);
308 case AifEnMirrorFailover: /* Mirror failover started */
309 device_printf(sc->aac_dev, "(MirrorFailover) "
310 "container %d failed, "
311 "migrating from slice %d to %d\n",
312 aif->data.EN.data.EMF.container,
313 aif->data.EN.data.EMF.failedSlice,
314 aif->data.EN.data.EMF.creatingSlice);
316 case AifEnContainerEvent: /* Significant container
318 device_printf(sc->aac_dev, "(ContainerEvent) "
319 "container %d event "
320 "%d\n", aif->data.EN.data.ECE.container,
321 aif->data.EN.data.ECE.eventType);
323 case AifEnFileSystemChange: /* File system changed */
324 device_printf(sc->aac_dev, "(FileSystemChange)\n");
326 case AifEnConfigPause: /* Container pause event */
327 device_printf(sc->aac_dev, "(ConfigPause)\n");
329 case AifEnConfigResume: /* Container resume event */
330 device_printf(sc->aac_dev, "(ConfigResume)\n");
332 case AifEnFailoverChange: /* Failover space assignment
334 device_printf(sc->aac_dev, "(FailoverChange)\n");
336 case AifEnRAID5RebuildDone: /* RAID5 rebuild finished */
337 device_printf(sc->aac_dev, "(RAID5RebuildDone)\n");
339 case AifEnEnclosureManagement: /* Enclosure management event */
340 device_printf(sc->aac_dev, "(EnclosureManagement) "
342 "event %d\n", aif->data.EN.data.EEE.empID,
343 aif->data.EN.data.EEE.unitID,
344 aif->data.EN.data.EEE.eventType);
346 case AifEnBatteryEvent: /* Significant NV battery
348 device_printf(sc->aac_dev, "(BatteryEvent) %d "
349 "(state was %d, is %d\n",
350 aif->data.EN.data.EBE.transition_type,
351 aif->data.EN.data.EBE.current_state,
352 aif->data.EN.data.EBE.prior_state);
354 case AifEnAddContainer: /* A new container was
356 device_printf(sc->aac_dev, "(AddContainer)\n");
358 case AifEnDeleteContainer: /* A container was deleted. */
359 device_printf(sc->aac_dev, "(DeleteContainer)\n");
361 case AifEnBatteryNeedsRecond: /* The battery needs
363 device_printf(sc->aac_dev, "(BatteryNeedsRecond)\n");
365 case AifEnClusterEvent: /* Some cluster event */
366 device_printf(sc->aac_dev, "(ClusterEvent) event %d\n",
367 aif->data.EN.data.ECLE.eventType);
369 case AifEnDiskSetEvent: /* A disk set event occured. */
370 device_printf(sc->aac_dev, "(DiskSetEvent) event %d "
371 "diskset %lld creator %lld\n",
372 aif->data.EN.data.EDS.eventType,
373 aif->data.EN.data.EDS.DsNum,
374 aif->data.EN.data.EDS.CreatorId);
376 case AifDenMorphComplete: /* A morph operation
378 device_printf(sc->aac_dev, "(MorphComplete)\n");
380 case AifDenVolumeExtendComplete: /* A volume expand operation
382 device_printf(sc->aac_dev, "(VolumeExtendComplete)\n");
385 device_printf(sc->aac_dev, "(%d)\n", aif->data.EN.type);
389 case AifCmdJobProgress:
392 switch(aif->data.PR[0].status) {
393 case AifJobStsSuccess:
394 status = "success"; break;
395 case AifJobStsFinished:
396 status = "finished"; break;
397 case AifJobStsAborted:
398 status = "aborted"; break;
399 case AifJobStsFailed:
400 status = "failed"; break;
401 case AifJobStsSuspended:
402 status = "suspended"; break;
403 case AifJobStsRunning:
404 status = "running"; break;
406 status = "unknown status"; break;
409 device_printf(sc->aac_dev, "JobProgress (%d) - %s (%d, %d)\n",
410 aif->seqNumber, status,
411 aif->data.PR[0].currentTick,
412 aif->data.PR[0].finalTick);
413 switch(aif->data.PR[0].jd.type) {
414 case AifJobScsiZero: /* SCSI dev clear operation */
415 device_printf(sc->aac_dev, "(ScsiZero) handle %d\n",
416 aif->data.PR[0].jd.client.scsi_dh);
418 case AifJobScsiVerify: /* SCSI device Verify operation
420 device_printf(sc->aac_dev, "(ScsiVerify) handle %d\n",
421 aif->data.PR[0].jd.client.scsi_dh);
423 case AifJobScsiExercise: /* SCSI device Exercise
425 device_printf(sc->aac_dev, "(ScsiExercise) handle %d\n",
426 aif->data.PR[0].jd.client.scsi_dh);
428 case AifJobScsiVerifyRepair: /* SCSI device Verify operation
430 device_printf(sc->aac_dev,
431 "(ScsiVerifyRepair) handle %d\n",
432 aif->data.PR[0].jd.client.scsi_dh);
434 case AifJobCtrZero: /* Container clear operation */
435 device_printf(sc->aac_dev,
436 "(ConatainerZero) container %d\n",
437 aif->data.PR[0].jd.client.container.src);
439 case AifJobCtrCopy: /* Container copy operation */
440 device_printf(sc->aac_dev,
441 "(ConatainerCopy) container %d to %d\n",
442 aif->data.PR[0].jd.client.container.src,
443 aif->data.PR[0].jd.client.container.dst);
445 case AifJobCtrCreateMirror: /* Container Create Mirror
447 device_printf(sc->aac_dev,
448 "(ConatainerCreateMirror) container %d\n",
449 aif->data.PR[0].jd.client.container.src);
450 /* XXX two containers? */
452 case AifJobCtrMergeMirror: /* Container Merge Mirror
454 device_printf(sc->aac_dev,
455 "(ConatainerMergeMirror) container %d\n",
456 aif->data.PR[0].jd.client.container.src);
457 /* XXX two containers? */
459 case AifJobCtrScrubMirror: /* Container Scrub Mirror
461 device_printf(sc->aac_dev,
462 "(ConatainerScrubMirror) container %d\n",
463 aif->data.PR[0].jd.client.container.src);
465 case AifJobCtrRebuildRaid5: /* Container Rebuild Raid5
467 device_printf(sc->aac_dev,
468 "(ConatainerRebuildRaid5) container %d\n",
469 aif->data.PR[0].jd.client.container.src);
471 case AifJobCtrScrubRaid5: /* Container Scrub Raid5
473 device_printf(sc->aac_dev,
474 "(ConatainerScrubRaid5) container %d\n",
475 aif->data.PR[0].jd.client.container.src);
477 case AifJobCtrMorph: /* Container morph operation */
478 device_printf(sc->aac_dev,
479 "(ConatainerMorph) container %d\n",
480 aif->data.PR[0].jd.client.container.src);
481 /* XXX two containers? */
483 case AifJobCtrPartCopy: /* Container Partition copy
485 device_printf(sc->aac_dev,
486 "(ConatainerPartCopy) container %d to "
488 aif->data.PR[0].jd.client.container.src,
489 aif->data.PR[0].jd.client.container.dst);
491 case AifJobCtrRebuildMirror: /* Container Rebuild Mirror
493 device_printf(sc->aac_dev,
494 "(ConatainerRebuildMirror) container "
496 aif->data.PR[0].jd.client.container.src);
498 case AifJobCtrCrazyCache: /* crazy cache */
499 device_printf(sc->aac_dev,
500 "(ConatainerCrazyCache) container %d\n",
501 aif->data.PR[0].jd.client.container.src);
502 /* XXX two containers? */
504 case AifJobFsCreate: /* File System Create
506 device_printf(sc->aac_dev, "(FsCreate)\n");
508 case AifJobFsVerify: /* File System Verify
510 device_printf(sc->aac_dev, "(FsVerivy)\n");
512 case AifJobFsExtend: /* File System Extend
514 device_printf(sc->aac_dev, "(FsExtend)\n");
516 case AifJobApiFormatNTFS: /* Format a drive to NTFS */
517 device_printf(sc->aac_dev, "(FormatNTFS)\n");
519 case AifJobApiFormatFAT: /* Format a drive to FAT */
520 device_printf(sc->aac_dev, "(FormatFAT)\n");
522 case AifJobApiUpdateSnapshot: /* update the read/write half
524 device_printf(sc->aac_dev, "(UpdateSnapshot)\n");
526 case AifJobApiFormatFAT32: /* Format a drive to FAT32 */
527 device_printf(sc->aac_dev, "(FormatFAT32)\n");
529 case AifJobCtlContinuousCtrVerify: /* Adapter operation */
530 device_printf(sc->aac_dev, "(ContinuousCtrVerify)\n");
533 device_printf(sc->aac_dev, "(%d)\n",
534 aif->data.PR[0].jd.type);
539 case AifCmdAPIReport:
540 device_printf(sc->aac_dev, "APIReport (%d)\n", aif->seqNumber);
542 case AifCmdDriverNotify:
543 device_printf(sc->aac_dev, "DriverNotify (%d)\n",
547 device_printf(sc->aac_dev, "AIF %d (%d)\n", aif->command,
552 #endif /* AAC_DEBUG */