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 $
30 * $DragonFly: src/sys/dev/raid/aac/aac_debug.c,v 1.4 2006/10/25 20:56:00 dillon Exp $
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/kernel.h>
42 #include "aac_compat.h"
44 #include <sys/devicestat.h>
48 #include "aac_ioctl.h"
52 void aac_printstate0(void);
56 * Dump the command queue indices
59 aac_print_queues(struct aac_softc *sc)
61 device_printf(sc->aac_dev, "FIB queue header at %p queues at %p\n",
62 &sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][0],
63 &sc->aac_queues->qt_HostNormCmdQueue[0]);
64 device_printf(sc->aac_dev, "HOST_NORM_CMD %d/%d (%d)\n",
65 sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][
67 sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][
69 AAC_HOST_NORM_CMD_ENTRIES);
70 device_printf(sc->aac_dev, "HOST_HIGH_CMD %d/%d (%d)\n",
71 sc->aac_queues->qt_qindex[AAC_HOST_HIGH_CMD_QUEUE][
73 sc->aac_queues->qt_qindex[AAC_HOST_HIGH_CMD_QUEUE][
75 AAC_HOST_HIGH_CMD_ENTRIES);
76 device_printf(sc->aac_dev, "ADAP_NORM_CMD %d/%d (%d)\n",
77 sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][
79 sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][
81 AAC_ADAP_NORM_CMD_ENTRIES);
82 device_printf(sc->aac_dev, "ADAP_HIGH_CMD %d/%d (%d)\n",
83 sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_CMD_QUEUE][
85 sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_CMD_QUEUE][
87 AAC_ADAP_HIGH_CMD_ENTRIES);
88 device_printf(sc->aac_dev, "HOST_NORM_RESP %d/%d (%d)\n",
89 sc->aac_queues->qt_qindex[AAC_HOST_NORM_RESP_QUEUE][
91 sc->aac_queues->qt_qindex[AAC_HOST_NORM_RESP_QUEUE][
93 AAC_HOST_NORM_RESP_ENTRIES);
94 device_printf(sc->aac_dev, "HOST_HIGH_RESP %d/%d (%d)\n",
95 sc->aac_queues->qt_qindex[AAC_HOST_HIGH_RESP_QUEUE][
97 sc->aac_queues->qt_qindex[AAC_HOST_HIGH_RESP_QUEUE][
99 AAC_HOST_HIGH_RESP_ENTRIES);
100 device_printf(sc->aac_dev, "ADAP_NORM_RESP %d/%d (%d)\n",
101 sc->aac_queues->qt_qindex[AAC_ADAP_NORM_RESP_QUEUE][
103 sc->aac_queues->qt_qindex[AAC_ADAP_NORM_RESP_QUEUE][
105 AAC_ADAP_NORM_RESP_ENTRIES);
106 device_printf(sc->aac_dev, "ADAP_HIGH_RESP %d/%d (%d)\n",
107 sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_RESP_QUEUE][
109 sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_RESP_QUEUE][
111 AAC_ADAP_HIGH_RESP_ENTRIES);
112 device_printf(sc->aac_dev, "AACQ_FREE %d/%d\n",
113 sc->aac_qstat[AACQ_FREE].q_length, sc->aac_qstat[AACQ_FREE].q_max);
114 device_printf(sc->aac_dev, "AACQ_BIO %d/%d\n",
115 sc->aac_qstat[AACQ_BIO].q_length, sc->aac_qstat[AACQ_BIO].q_max);
116 device_printf(sc->aac_dev, "AACQ_READY %d/%d\n",
117 sc->aac_qstat[AACQ_READY].q_length,
118 sc->aac_qstat[AACQ_READY].q_max);
119 device_printf(sc->aac_dev, "AACQ_BUSY %d/%d\n",
120 sc->aac_qstat[AACQ_BUSY].q_length, sc->aac_qstat[AACQ_BUSY].q_max);
121 device_printf(sc->aac_dev, "AACQ_COMPLETE %d/%d\n",
122 sc->aac_qstat[AACQ_COMPLETE].q_length,
123 sc->aac_qstat[AACQ_COMPLETE].q_max);
127 * Print the command queue states for controller 0 (callable from DDB)
130 aac_printstate0(void)
132 struct aac_softc *sc;
134 sc = devclass_get_softc(aac_devclass, 0);
136 aac_print_queues(sc);
137 switch (sc->aac_hwif) {
138 case AAC_HWIF_I960RX:
139 device_printf(sc->aac_dev, "IDBR 0x%08x IIMR 0x%08x "
140 "IISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_IDBR),
141 AAC_GETREG4(sc, AAC_RX_IIMR), AAC_GETREG4(sc, AAC_RX_IISR));
142 device_printf(sc->aac_dev, "ODBR 0x%08x OIMR 0x%08x "
143 "OISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_ODBR),
144 AAC_GETREG4(sc, AAC_RX_OIMR), AAC_GETREG4(sc, AAC_RX_OISR));
145 AAC_SETREG4(sc, AAC_RX_OIMR, 0/*~(AAC_DB_COMMAND_READY |
146 AAC_DB_RESPONSE_READY | AAC_DB_PRINTF)*/);
147 device_printf(sc->aac_dev, "ODBR 0x%08x OIMR 0x%08x "
148 "OISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_ODBR),
149 AAC_GETREG4(sc, AAC_RX_OIMR), AAC_GETREG4(sc, AAC_RX_OISR));
151 case AAC_HWIF_STRONGARM:
157 * simulate an interrupt for controller 0
162 struct aac_softc *sc;
164 sc = devclass_get_softc(aac_devclass, 0);
170 * Panic in a slightly informative fashion
173 aac_panic(struct aac_softc *sc, char *reason)
175 aac_print_queues(sc);
183 aac_print_fib(struct aac_softc *sc, struct aac_fib *fib, char *caller)
186 device_printf(sc->aac_dev,
187 "aac_print_fib called with NULL fib\n");
190 device_printf(sc->aac_dev, "%s: FIB @ %p\n", caller, fib);
191 device_printf(sc->aac_dev, " XferState %b\n", fib->Header.XferState,
214 device_printf(sc->aac_dev, " Command %d\n", fib->Header.Command);
215 device_printf(sc->aac_dev, " StructType %d\n",
216 fib->Header.StructType);
217 device_printf(sc->aac_dev, " Flags 0x%x\n", fib->Header.Flags);
218 device_printf(sc->aac_dev, " Size %d\n", fib->Header.Size);
219 device_printf(sc->aac_dev, " SenderSize %d\n",
220 fib->Header.SenderSize);
221 device_printf(sc->aac_dev, " SenderAddress 0x%x\n",
222 fib->Header.SenderFibAddress);
223 device_printf(sc->aac_dev, " RcvrAddress 0x%x\n",
224 fib->Header.ReceiverFibAddress);
225 device_printf(sc->aac_dev, " SenderData 0x%x\n",
226 fib->Header.SenderData);
227 switch(fib->Header.Command) {
228 case ContainerCommand:
230 struct aac_blockread *br;
231 struct aac_blockwrite *bw;
232 struct aac_sg_table *sg;
235 br = (struct aac_blockread*)fib->data;
236 bw = (struct aac_blockwrite*)fib->data;
239 if (br->Command == VM_CtBlockRead) {
240 device_printf(sc->aac_dev,
241 " BlockRead: container %d 0x%x/%d\n",
242 br->ContainerId, br->BlockNumber,
246 if (bw->Command == VM_CtBlockWrite) {
247 device_printf(sc->aac_dev,
248 " BlockWrite: container %d 0x%x/%d "
249 "(%s)\n", bw->ContainerId,
250 bw->BlockNumber, bw->ByteCount,
251 bw->Stable == CSTABLE ? "stable" :
256 device_printf(sc->aac_dev,
257 " %d s/g entries\n", sg->SgCount);
258 for (i = 0; i < sg->SgCount; i++)
259 device_printf(sc->aac_dev, " 0x%08x/%d\n",
260 sg->SgEntry[i].SgAddress,
261 sg->SgEntry[i].SgByteCount);
266 device_printf(sc->aac_dev, " %16D\n", fib->data, " ");
267 device_printf(sc->aac_dev, " %16D\n", fib->data + 16, " ");
273 * Describe an AIF we have received.
276 aac_print_aif(struct aac_softc *sc, struct aac_aif_command *aif)
278 switch(aif->command) {
279 case AifCmdEventNotify:
280 device_printf(sc->aac_dev, "EventNotify(%d)\n", aif->seqNumber);
281 switch(aif->data.EN.type) {
282 case AifEnGeneric: /* Generic notification */
283 device_printf(sc->aac_dev, "(Generic) %.*s\n",
284 (int)sizeof(aif->data.EN.data.EG),
285 aif->data.EN.data.EG.text);
287 case AifEnTaskComplete: /* Task has completed */
288 device_printf(sc->aac_dev, "(TaskComplete)\n");
290 case AifEnConfigChange: /* Adapter configuration change
292 device_printf(sc->aac_dev, "(ConfigChange)\n");
294 case AifEnContainerChange: /* Adapter specific container
295 * configuration change */
296 device_printf(sc->aac_dev, "(ContainerChange) "
298 aif->data.EN.data.ECC.container[0],
299 aif->data.EN.data.ECC.container[1]);
301 case AifEnDeviceFailure: /* SCSI device failed */
302 device_printf(sc->aac_dev, "(DeviceFailure) "
304 aif->data.EN.data.EDF.deviceHandle);
306 case AifEnMirrorFailover: /* Mirror failover started */
307 device_printf(sc->aac_dev, "(MirrorFailover) "
308 "container %d failed, "
309 "migrating from slice %d to %d\n",
310 aif->data.EN.data.EMF.container,
311 aif->data.EN.data.EMF.failedSlice,
312 aif->data.EN.data.EMF.creatingSlice);
314 case AifEnContainerEvent: /* Significant container
316 device_printf(sc->aac_dev, "(ContainerEvent) "
317 "container %d event "
318 "%d\n", aif->data.EN.data.ECE.container,
319 aif->data.EN.data.ECE.eventType);
321 case AifEnFileSystemChange: /* File system changed */
322 device_printf(sc->aac_dev, "(FileSystemChange)\n");
324 case AifEnConfigPause: /* Container pause event */
325 device_printf(sc->aac_dev, "(ConfigPause)\n");
327 case AifEnConfigResume: /* Container resume event */
328 device_printf(sc->aac_dev, "(ConfigResume)\n");
330 case AifEnFailoverChange: /* Failover space assignment
332 device_printf(sc->aac_dev, "(FailoverChange)\n");
334 case AifEnRAID5RebuildDone: /* RAID5 rebuild finished */
335 device_printf(sc->aac_dev, "(RAID5RebuildDone)\n");
337 case AifEnEnclosureManagement: /* Enclosure management event */
338 device_printf(sc->aac_dev, "(EnclosureManagement) "
340 "event %d\n", aif->data.EN.data.EEE.empID,
341 aif->data.EN.data.EEE.unitID,
342 aif->data.EN.data.EEE.eventType);
344 case AifEnBatteryEvent: /* Significant NV battery
346 device_printf(sc->aac_dev, "(BatteryEvent) %d "
347 "(state was %d, is %d\n",
348 aif->data.EN.data.EBE.transition_type,
349 aif->data.EN.data.EBE.current_state,
350 aif->data.EN.data.EBE.prior_state);
352 case AifEnAddContainer: /* A new container was
354 device_printf(sc->aac_dev, "(AddContainer)\n");
356 case AifEnDeleteContainer: /* A container was deleted. */
357 device_printf(sc->aac_dev, "(DeleteContainer)\n");
359 case AifEnBatteryNeedsRecond: /* The battery needs
361 device_printf(sc->aac_dev, "(BatteryNeedsRecond)\n");
363 case AifEnClusterEvent: /* Some cluster event */
364 device_printf(sc->aac_dev, "(ClusterEvent) event %d\n",
365 aif->data.EN.data.ECLE.eventType);
367 case AifEnDiskSetEvent: /* A disk set event occured. */
368 device_printf(sc->aac_dev, "(DiskSetEvent) event %d "
369 "diskset %lld creator %lld\n",
370 aif->data.EN.data.EDS.eventType,
371 aif->data.EN.data.EDS.DsNum,
372 aif->data.EN.data.EDS.CreatorId);
374 case AifDenMorphComplete: /* A morph operation
376 device_printf(sc->aac_dev, "(MorphComplete)\n");
378 case AifDenVolumeExtendComplete: /* A volume expand operation
380 device_printf(sc->aac_dev, "(VolumeExtendComplete)\n");
383 device_printf(sc->aac_dev, "(%d)\n", aif->data.EN.type);
387 case AifCmdJobProgress:
390 switch(aif->data.PR[0].status) {
391 case AifJobStsSuccess:
392 status = "success"; break;
393 case AifJobStsFinished:
394 status = "finished"; break;
395 case AifJobStsAborted:
396 status = "aborted"; break;
397 case AifJobStsFailed:
398 status = "failed"; break;
399 case AifJobStsSuspended:
400 status = "suspended"; break;
401 case AifJobStsRunning:
402 status = "running"; break;
404 status = "unknown status"; break;
407 device_printf(sc->aac_dev, "JobProgress (%d) - %s (%d, %d)\n",
408 aif->seqNumber, status,
409 aif->data.PR[0].currentTick,
410 aif->data.PR[0].finalTick);
411 switch(aif->data.PR[0].jd.type) {
412 case AifJobScsiZero: /* SCSI dev clear operation */
413 device_printf(sc->aac_dev, "(ScsiZero) handle %d\n",
414 aif->data.PR[0].jd.client.scsi_dh);
416 case AifJobScsiVerify: /* SCSI device Verify operation
418 device_printf(sc->aac_dev, "(ScsiVerify) handle %d\n",
419 aif->data.PR[0].jd.client.scsi_dh);
421 case AifJobScsiExercise: /* SCSI device Exercise
423 device_printf(sc->aac_dev, "(ScsiExercise) handle %d\n",
424 aif->data.PR[0].jd.client.scsi_dh);
426 case AifJobScsiVerifyRepair: /* SCSI device Verify operation
428 device_printf(sc->aac_dev,
429 "(ScsiVerifyRepair) handle %d\n",
430 aif->data.PR[0].jd.client.scsi_dh);
432 case AifJobCtrZero: /* Container clear operation */
433 device_printf(sc->aac_dev,
434 "(ConatainerZero) container %d\n",
435 aif->data.PR[0].jd.client.container.src);
437 case AifJobCtrCopy: /* Container copy operation */
438 device_printf(sc->aac_dev,
439 "(ConatainerCopy) container %d to %d\n",
440 aif->data.PR[0].jd.client.container.src,
441 aif->data.PR[0].jd.client.container.dst);
443 case AifJobCtrCreateMirror: /* Container Create Mirror
445 device_printf(sc->aac_dev,
446 "(ConatainerCreateMirror) container %d\n",
447 aif->data.PR[0].jd.client.container.src);
448 /* XXX two containers? */
450 case AifJobCtrMergeMirror: /* Container Merge Mirror
452 device_printf(sc->aac_dev,
453 "(ConatainerMergeMirror) container %d\n",
454 aif->data.PR[0].jd.client.container.src);
455 /* XXX two containers? */
457 case AifJobCtrScrubMirror: /* Container Scrub Mirror
459 device_printf(sc->aac_dev,
460 "(ConatainerScrubMirror) container %d\n",
461 aif->data.PR[0].jd.client.container.src);
463 case AifJobCtrRebuildRaid5: /* Container Rebuild Raid5
465 device_printf(sc->aac_dev,
466 "(ConatainerRebuildRaid5) container %d\n",
467 aif->data.PR[0].jd.client.container.src);
469 case AifJobCtrScrubRaid5: /* Container Scrub Raid5
471 device_printf(sc->aac_dev,
472 "(ConatainerScrubRaid5) container %d\n",
473 aif->data.PR[0].jd.client.container.src);
475 case AifJobCtrMorph: /* Container morph operation */
476 device_printf(sc->aac_dev,
477 "(ConatainerMorph) container %d\n",
478 aif->data.PR[0].jd.client.container.src);
479 /* XXX two containers? */
481 case AifJobCtrPartCopy: /* Container Partition copy
483 device_printf(sc->aac_dev,
484 "(ConatainerPartCopy) container %d to "
486 aif->data.PR[0].jd.client.container.src,
487 aif->data.PR[0].jd.client.container.dst);
489 case AifJobCtrRebuildMirror: /* Container Rebuild Mirror
491 device_printf(sc->aac_dev,
492 "(ConatainerRebuildMirror) container "
494 aif->data.PR[0].jd.client.container.src);
496 case AifJobCtrCrazyCache: /* crazy cache */
497 device_printf(sc->aac_dev,
498 "(ConatainerCrazyCache) container %d\n",
499 aif->data.PR[0].jd.client.container.src);
500 /* XXX two containers? */
502 case AifJobFsCreate: /* File System Create
504 device_printf(sc->aac_dev, "(FsCreate)\n");
506 case AifJobFsVerify: /* File System Verify
508 device_printf(sc->aac_dev, "(FsVerivy)\n");
510 case AifJobFsExtend: /* File System Extend
512 device_printf(sc->aac_dev, "(FsExtend)\n");
514 case AifJobApiFormatNTFS: /* Format a drive to NTFS */
515 device_printf(sc->aac_dev, "(FormatNTFS)\n");
517 case AifJobApiFormatFAT: /* Format a drive to FAT */
518 device_printf(sc->aac_dev, "(FormatFAT)\n");
520 case AifJobApiUpdateSnapshot: /* update the read/write half
522 device_printf(sc->aac_dev, "(UpdateSnapshot)\n");
524 case AifJobApiFormatFAT32: /* Format a drive to FAT32 */
525 device_printf(sc->aac_dev, "(FormatFAT32)\n");
527 case AifJobCtlContinuousCtrVerify: /* Adapter operation */
528 device_printf(sc->aac_dev, "(ContinuousCtrVerify)\n");
531 device_printf(sc->aac_dev, "(%d)\n",
532 aif->data.PR[0].jd.type);
537 case AifCmdAPIReport:
538 device_printf(sc->aac_dev, "APIReport (%d)\n", aif->seqNumber);
540 case AifCmdDriverNotify:
541 device_printf(sc->aac_dev, "DriverNotify (%d)\n",
545 device_printf(sc->aac_dev, "AIF %d (%d)\n", aif->command,
550 #endif /* AAC_DEBUG */