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
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/kernel.h>
45 #include <machine/resource.h>
46 #include <machine/bus.h>
48 #include <dev/aac/aacreg.h>
49 #include <sys/aac_ioctl.h>
50 #include <dev/aac/aacvar.h>
53 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);
124 * Print the command queue states for controller 0 (callable from DDB)
127 aac_printstate0(void)
129 struct aac_softc *sc;
131 sc = devclass_get_softc(devclass_find("aac"), 0);
133 aac_print_queues(sc);
134 switch (sc->aac_hwif) {
135 case AAC_HWIF_I960RX:
136 device_printf(sc->aac_dev, "IDBR 0x%08x IIMR 0x%08x "
137 "IISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_IDBR),
138 AAC_GETREG4(sc, AAC_RX_IIMR), AAC_GETREG4(sc, AAC_RX_IISR));
139 device_printf(sc->aac_dev, "ODBR 0x%08x OIMR 0x%08x "
140 "OISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_ODBR),
141 AAC_GETREG4(sc, AAC_RX_OIMR), AAC_GETREG4(sc, AAC_RX_OISR));
142 AAC_SETREG4(sc, AAC_RX_OIMR, 0/*~(AAC_DB_COMMAND_READY |
143 AAC_DB_RESPONSE_READY | AAC_DB_PRINTF)*/);
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));
148 case AAC_HWIF_STRONGARM:
155 * Panic in a slightly informative fashion
158 aac_panic(struct aac_softc *sc, char *reason)
160 aac_print_queues(sc);
168 aac_print_fib(struct aac_softc *sc, struct aac_fib *fib, const char *caller)
171 device_printf(sc->aac_dev,
172 "aac_print_fib called with NULL fib\n");
175 device_printf(sc->aac_dev, "%s: FIB @ %p\n", caller, fib);
176 device_printf(sc->aac_dev, " XferState %b\n", fib->Header.XferState,
199 device_printf(sc->aac_dev, " Command %d\n", fib->Header.Command);
200 device_printf(sc->aac_dev, " StructType %d\n",
201 fib->Header.StructType);
202 device_printf(sc->aac_dev, " Flags 0x%x\n", fib->Header.Flags);
203 device_printf(sc->aac_dev, " Size %d\n", fib->Header.Size);
204 device_printf(sc->aac_dev, " SenderSize %d\n",
205 fib->Header.SenderSize);
206 device_printf(sc->aac_dev, " SenderAddress 0x%x\n",
207 fib->Header.SenderFibAddress);
208 device_printf(sc->aac_dev, " RcvrAddress 0x%x\n",
209 fib->Header.ReceiverFibAddress);
210 device_printf(sc->aac_dev, " SenderData 0x%x\n",
211 fib->Header.SenderData);
212 switch(fib->Header.Command) {
213 case ContainerCommand:
215 struct aac_blockread *br;
216 struct aac_blockwrite *bw;
217 struct aac_sg_table *sg;
220 br = (struct aac_blockread*)fib->data;
221 bw = (struct aac_blockwrite*)fib->data;
224 if (br->Command == VM_CtBlockRead) {
225 device_printf(sc->aac_dev,
226 " BlockRead: container %d 0x%x/%d\n",
227 br->ContainerId, br->BlockNumber,
231 if (bw->Command == VM_CtBlockWrite) {
232 device_printf(sc->aac_dev,
233 " BlockWrite: container %d 0x%x/%d "
234 "(%s)\n", bw->ContainerId,
235 bw->BlockNumber, bw->ByteCount,
236 bw->Stable == CSTABLE ? "stable" :
241 device_printf(sc->aac_dev,
242 " %d s/g entries\n", sg->SgCount);
243 for (i = 0; i < sg->SgCount; i++)
244 device_printf(sc->aac_dev, " 0x%08x/%d\n",
245 sg->SgEntry[i].SgAddress,
246 sg->SgEntry[i].SgByteCount);
251 device_printf(sc->aac_dev, " %16D\n", fib->data, " ");
252 device_printf(sc->aac_dev, " %16D\n", fib->data + 16, " ");
258 * Describe an AIF we have received.
261 aac_print_aif(struct aac_softc *sc, struct aac_aif_command *aif)
263 switch(aif->command) {
264 case AifCmdEventNotify:
265 device_printf(sc->aac_dev, "EventNotify(%d)\n", aif->seqNumber);
266 switch(aif->data.EN.type) {
267 case AifEnGeneric: /* Generic notification */
268 device_printf(sc->aac_dev, "(Generic) %.*s\n",
269 (int)sizeof(aif->data.EN.data.EG),
270 aif->data.EN.data.EG.text);
272 case AifEnTaskComplete: /* Task has completed */
273 device_printf(sc->aac_dev, "(TaskComplete)\n");
275 case AifEnConfigChange: /* Adapter configuration change
277 device_printf(sc->aac_dev, "(ConfigChange)\n");
279 case AifEnContainerChange: /* Adapter specific container
280 * configuration change */
281 device_printf(sc->aac_dev, "(ContainerChange) "
283 aif->data.EN.data.ECC.container[0],
284 aif->data.EN.data.ECC.container[1]);
286 case AifEnDeviceFailure: /* SCSI device failed */
287 device_printf(sc->aac_dev, "(DeviceFailure) "
289 aif->data.EN.data.EDF.deviceHandle);
291 case AifEnMirrorFailover: /* Mirror failover started */
292 device_printf(sc->aac_dev, "(MirrorFailover) "
293 "container %d failed, "
294 "migrating from slice %d to %d\n",
295 aif->data.EN.data.EMF.container,
296 aif->data.EN.data.EMF.failedSlice,
297 aif->data.EN.data.EMF.creatingSlice);
299 case AifEnContainerEvent: /* Significant container
301 device_printf(sc->aac_dev, "(ContainerEvent) "
302 "container %d event "
303 "%d\n", aif->data.EN.data.ECE.container,
304 aif->data.EN.data.ECE.eventType);
306 case AifEnFileSystemChange: /* File system changed */
307 device_printf(sc->aac_dev, "(FileSystemChange)\n");
309 case AifEnConfigPause: /* Container pause event */
310 device_printf(sc->aac_dev, "(ConfigPause)\n");
312 case AifEnConfigResume: /* Container resume event */
313 device_printf(sc->aac_dev, "(ConfigResume)\n");
315 case AifEnFailoverChange: /* Failover space assignment
317 device_printf(sc->aac_dev, "(FailoverChange)\n");
319 case AifEnRAID5RebuildDone: /* RAID5 rebuild finished */
320 device_printf(sc->aac_dev, "(RAID5RebuildDone)\n");
322 case AifEnEnclosureManagement: /* Enclosure management event */
323 device_printf(sc->aac_dev, "(EnclosureManagement) "
325 "event %d\n", aif->data.EN.data.EEE.empID,
326 aif->data.EN.data.EEE.unitID,
327 aif->data.EN.data.EEE.eventType);
329 case AifEnBatteryEvent: /* Significant NV battery
331 device_printf(sc->aac_dev, "(BatteryEvent) %d "
332 "(state was %d, is %d\n",
333 aif->data.EN.data.EBE.transition_type,
334 aif->data.EN.data.EBE.current_state,
335 aif->data.EN.data.EBE.prior_state);
337 case AifEnAddContainer: /* A new container was
339 device_printf(sc->aac_dev, "(AddContainer)\n");
341 case AifEnDeleteContainer: /* A container was deleted. */
342 device_printf(sc->aac_dev, "(DeleteContainer)\n");
344 case AifEnBatteryNeedsRecond: /* The battery needs
346 device_printf(sc->aac_dev, "(BatteryNeedsRecond)\n");
348 case AifEnClusterEvent: /* Some cluster event */
349 device_printf(sc->aac_dev, "(ClusterEvent) event %d\n",
350 aif->data.EN.data.ECLE.eventType);
352 case AifEnDiskSetEvent: /* A disk set event occured. */
353 device_printf(sc->aac_dev, "(DiskSetEvent) event %d "
354 "diskset %jd creator %jd\n",
355 aif->data.EN.data.EDS.eventType,
356 (intmax_t)aif->data.EN.data.EDS.DsNum,
357 (intmax_t)aif->data.EN.data.EDS.CreatorId);
359 case AifDenMorphComplete: /* A morph operation
361 device_printf(sc->aac_dev, "(MorphComplete)\n");
363 case AifDenVolumeExtendComplete: /* A volume expand operation
365 device_printf(sc->aac_dev, "(VolumeExtendComplete)\n");
368 device_printf(sc->aac_dev, "(%d)\n", aif->data.EN.type);
372 case AifCmdJobProgress:
375 switch(aif->data.PR[0].status) {
376 case AifJobStsSuccess:
377 status = "success"; break;
378 case AifJobStsFinished:
379 status = "finished"; break;
380 case AifJobStsAborted:
381 status = "aborted"; break;
382 case AifJobStsFailed:
383 status = "failed"; break;
384 case AifJobStsSuspended:
385 status = "suspended"; break;
386 case AifJobStsRunning:
387 status = "running"; break;
389 status = "unknown status"; break;
392 device_printf(sc->aac_dev, "JobProgress (%d) - %s (%d, %d)\n",
393 aif->seqNumber, status,
394 aif->data.PR[0].currentTick,
395 aif->data.PR[0].finalTick);
396 switch(aif->data.PR[0].jd.type) {
397 case AifJobScsiZero: /* SCSI dev clear operation */
398 device_printf(sc->aac_dev, "(ScsiZero) handle %d\n",
399 aif->data.PR[0].jd.client.scsi_dh);
401 case AifJobScsiVerify: /* SCSI device Verify operation
403 device_printf(sc->aac_dev, "(ScsiVerify) handle %d\n",
404 aif->data.PR[0].jd.client.scsi_dh);
406 case AifJobScsiExercise: /* SCSI device Exercise
408 device_printf(sc->aac_dev, "(ScsiExercise) handle %d\n",
409 aif->data.PR[0].jd.client.scsi_dh);
411 case AifJobScsiVerifyRepair: /* SCSI device Verify operation
413 device_printf(sc->aac_dev,
414 "(ScsiVerifyRepair) handle %d\n",
415 aif->data.PR[0].jd.client.scsi_dh);
417 case AifJobCtrZero: /* Container clear operation */
418 device_printf(sc->aac_dev,
419 "(ContainerZero) container %d\n",
420 aif->data.PR[0].jd.client.container.src);
422 case AifJobCtrCopy: /* Container copy operation */
423 device_printf(sc->aac_dev,
424 "(ContainerCopy) container %d to %d\n",
425 aif->data.PR[0].jd.client.container.src,
426 aif->data.PR[0].jd.client.container.dst);
428 case AifJobCtrCreateMirror: /* Container Create Mirror
430 device_printf(sc->aac_dev,
431 "(ContainerCreateMirror) container %d\n",
432 aif->data.PR[0].jd.client.container.src);
433 /* XXX two containers? */
435 case AifJobCtrMergeMirror: /* Container Merge Mirror
437 device_printf(sc->aac_dev,
438 "(ContainerMergeMirror) container %d\n",
439 aif->data.PR[0].jd.client.container.src);
440 /* XXX two containers? */
442 case AifJobCtrScrubMirror: /* Container Scrub Mirror
444 device_printf(sc->aac_dev,
445 "(ContainerScrubMirror) container %d\n",
446 aif->data.PR[0].jd.client.container.src);
448 case AifJobCtrRebuildRaid5: /* Container Rebuild Raid5
450 device_printf(sc->aac_dev,
451 "(ContainerRebuildRaid5) container %d\n",
452 aif->data.PR[0].jd.client.container.src);
454 case AifJobCtrScrubRaid5: /* Container Scrub Raid5
456 device_printf(sc->aac_dev,
457 "(ContainerScrubRaid5) container %d\n",
458 aif->data.PR[0].jd.client.container.src);
460 case AifJobCtrMorph: /* Container morph operation */
461 device_printf(sc->aac_dev,
462 "(ContainerMorph) container %d\n",
463 aif->data.PR[0].jd.client.container.src);
464 /* XXX two containers? */
466 case AifJobCtrPartCopy: /* Container Partition copy
468 device_printf(sc->aac_dev,
469 "(ContainerPartCopy) container %d to "
471 aif->data.PR[0].jd.client.container.src,
472 aif->data.PR[0].jd.client.container.dst);
474 case AifJobCtrRebuildMirror: /* Container Rebuild Mirror
476 device_printf(sc->aac_dev,
477 "(ContainerRebuildMirror) container "
479 aif->data.PR[0].jd.client.container.src);
481 case AifJobCtrCrazyCache: /* crazy cache */
482 device_printf(sc->aac_dev,
483 "(ContainerCrazyCache) container %d\n",
484 aif->data.PR[0].jd.client.container.src);
485 /* XXX two containers? */
487 case AifJobFsCreate: /* File System Create
489 device_printf(sc->aac_dev, "(FsCreate)\n");
491 case AifJobFsVerify: /* File System Verify
493 device_printf(sc->aac_dev, "(FsVerivy)\n");
495 case AifJobFsExtend: /* File System Extend
497 device_printf(sc->aac_dev, "(FsExtend)\n");
499 case AifJobApiFormatNTFS: /* Format a drive to NTFS */
500 device_printf(sc->aac_dev, "(FormatNTFS)\n");
502 case AifJobApiFormatFAT: /* Format a drive to FAT */
503 device_printf(sc->aac_dev, "(FormatFAT)\n");
505 case AifJobApiUpdateSnapshot: /* update the read/write half
507 device_printf(sc->aac_dev, "(UpdateSnapshot)\n");
509 case AifJobApiFormatFAT32: /* Format a drive to FAT32 */
510 device_printf(sc->aac_dev, "(FormatFAT32)\n");
512 case AifJobCtlContinuousCtrVerify: /* Adapter operation */
513 device_printf(sc->aac_dev, "(ContinuousCtrVerify)\n");
516 device_printf(sc->aac_dev, "(%d)\n",
517 aif->data.PR[0].jd.type);
522 case AifCmdAPIReport:
523 device_printf(sc->aac_dev, "APIReport (%d)\n", aif->seqNumber);
525 case AifCmdDriverNotify:
526 device_printf(sc->aac_dev, "DriverNotify (%d)\n",
530 device_printf(sc->aac_dev, "AIF %d (%d)\n", aif->command,
535 #endif /* AAC_DEBUG */