summaryrefslogtreecommitdiffstats
path: root/sys/dev/mfi/mfi_debug.c
diff options
context:
space:
mode:
authorscottl <scottl@FreeBSD.org>2006-10-16 04:18:38 +0000
committerscottl <scottl@FreeBSD.org>2006-10-16 04:18:38 +0000
commit012e27daa11e6811c981d259dc0bb43ce54792a0 (patch)
treef9ab8d12d2f604c26a086cb17a9be1266d38f051 /sys/dev/mfi/mfi_debug.c
parent9b96c4f62e46173803871c0f01be5afa7d5de80d (diff)
downloadFreeBSD-src-012e27daa11e6811c981d259dc0bb43ce54792a0.zip
FreeBSD-src-012e27daa11e6811c981d259dc0bb43ce54792a0.tar.gz
- Add a command validator for use in debugging.
- Fix the locking protocol to eliminate races between normal I/O and AENs. - Various small improvements and usability tweaks. Sponsored by: IronPort Portions Submitted by: Doug Ambrisko
Diffstat (limited to 'sys/dev/mfi/mfi_debug.c')
-rw-r--r--sys/dev/mfi/mfi_debug.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/sys/dev/mfi/mfi_debug.c b/sys/dev/mfi/mfi_debug.c
index 5cd2d35..515e6ed 100644
--- a/sys/dev/mfi/mfi_debug.c
+++ b/sys/dev/mfi/mfi_debug.c
@@ -46,6 +46,9 @@ __FBSDID("$FreeBSD$");
#include <machine/resource.h>
#include <machine/bus.h>
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
#include <dev/mfi/mfireg.h>
#include <dev/mfi/mfi_ioctl.h>
#include <dev/mfi/mfivar.h>
@@ -225,4 +228,36 @@ mfi_dump_cmds(struct mfi_softc *sc)
mfi_print_generic_frame(sc, &sc->mfi_commands[i]);
}
+void
+mfi_validate_sg(struct mfi_softc *sc, struct mfi_command *cm,
+ const char *function, int line)
+{
+ struct mfi_frame_header *hdr;
+ int i;
+ uint32_t count = 0, data_len;
+
+ hdr = &cm->cm_frame->header;
+ count = 0;
+ for (i = 0; i < hdr->sg_count; i++) {
+ count += cm->cm_sg->sg32[i].len;
+ }
+ /*
+ count++;
+ */
+ data_len = hdr->data_len;
+ switch (hdr->cmd) {
+ case MFI_CMD_LD_READ:
+ case MFI_CMD_LD_WRITE:
+ data_len = data_len * 512;
+ case MFI_CMD_DCMD:
+ if (count != data_len) {
+ device_printf(sc->mfi_dev,
+ "%s %d COMMAND %p S/G count bad %d %d %d 0x%jx\n",
+ function, line, cm, count, data_len, cm->cm_len,
+ (intmax_t)pmap_kextract((vm_offset_t)cm->cm_data));
+ MFI_PRINT_CMD(cm);
+ }
+ }
+}
+
#endif
OpenPOWER on IntegriCloud