[Qemu-devel] [PATCH 3/3] megasas: Add trace events
This patch add trace events to the megasas HBA emulation. Signed-off-by: Hannes Reinecke h...@suse.de --- hw/megasas.c | 348 +- trace-events | 79 + 2 files changed, 377 insertions(+), 50 deletions(-) diff --git a/hw/megasas.c b/hw/megasas.c index bf5f8cd..af7f175 100644 --- a/hw/megasas.c +++ b/hw/megasas.c @@ -26,6 +26,7 @@ #include scsi.h #include scsi-defs.h #include block_int.h +#include trace.h #include mfi.h @@ -221,6 +222,8 @@ static int megasas_map_sgl(MegasasCmd *cmd, union mfi_sgl *sgl) cmd-flags = le16_to_cpu(cmd-frame-header.flags); iov_count = cmd-frame-header.sge_count; if (iov_count MEGASAS_MAX_SGE) { +trace_megasas_iovec_sgl_overflow(cmd-index, iov_count, + MEGASAS_MAX_SGE); return iov_count; } qemu_sglist_init(cmd-qsg, iov_count); @@ -228,17 +231,25 @@ static int megasas_map_sgl(MegasasCmd *cmd, union mfi_sgl *sgl) dma_addr_t iov_pa, iov_size_p; if (!sgl) { +trace_megasas_iovec_sgl_underflow(cmd-index, i); goto unmap; } iov_pa = megasas_sgl_get_addr(cmd, sgl); iov_size_p = megasas_sgl_get_len(cmd, sgl); if (!iov_pa || !iov_size_p) { +trace_megasas_iovec_sgl_invalid(cmd-index, i, +iov_pa, iov_size_p); goto unmap; } qemu_sglist_add(cmd-qsg, iov_pa, iov_size_p); sgl = megasas_sgl_next(cmd, sgl); iov_size += (size_t)iov_size_p; } +if (cmd-iov_size iov_size) { +trace_megasas_iovec_overflow(cmd-index, iov_size, cmd-iov_size); +} else if (cmd-iov_size iov_size) { +trace_megasas_iovec_underflow(cmd-iov_size, iov_size, cmd-iov_size); +} cmd-iov_offset = 0; return 0; unmap: @@ -411,6 +422,7 @@ static MegasasCmd *megasas_next_frame(MegasasState *s, cmd = megasas_lookup_frame(s, frame); if (cmd) { +trace_megasas_qf_found(cmd-index, cmd-pa); return cmd; } index = s-reply_queue_head; @@ -423,6 +435,10 @@ static MegasasCmd *megasas_next_frame(MegasasState *s, index = megasas_next_index(s, index, s-fw_cmds); num++; } +if (!cmd) { +trace_megasas_qf_failed(frame); +} +trace_megasas_qf_new(index, cmd); return cmd; } @@ -443,6 +459,7 @@ static MegasasCmd *megasas_enqueue_frame(MegasasState *s, /* Map all possible frames */ cmd-frame = cpu_physical_memory_map(frame, frame_size_p, 0); if (frame_size_p != frame_size) { +trace_megasas_qf_map_failed(cmd-index, (unsigned long)frame); if (cmd-frame) { cpu_physical_memory_unmap(cmd-frame, frame_size_p, 0, 0); cmd-frame = NULL; @@ -460,6 +477,9 @@ static MegasasCmd *megasas_enqueue_frame(MegasasState *s, cmd-count = count; s-busy++; +trace_megasas_qf_enqueue(cmd-index, cmd-count, cmd-context, + s-reply_queue_head, s-busy); + return cmd; } @@ -485,6 +505,8 @@ static void megasas_complete_frame(MegasasState *s, uint64_t context) stl_le_phys(s-reply_queue_pa + queue_offset, context); } s-reply_queue_head = megasas_next_index(s, tail, s-fw_cmds); +trace_megasas_qf_complete(context, tail, queue_offset, + s-busy, s-doorbell); } if (megasas_intr_enabled(s)) { @@ -492,11 +514,15 @@ static void megasas_complete_frame(MegasasState *s, uint64_t context) s-doorbell++; if (s-doorbell == 1) { if (msix_enabled(s-dev)) { +trace_megasas_msix_raise(0); msix_notify(s-dev, 0); } else { +trace_megasas_irq_raise(); qemu_irq_raise(s-dev.irq[0]); } } +} else { +trace_megasas_qf_complete_noirq(context); } } @@ -534,15 +560,18 @@ static int megasas_init_firmware(MegasasState *s, MegasasCmd *cmd) pa_lo = le32_to_cpu(cmd-frame-init.qinfo_new_addr_lo); pa_hi = le32_to_cpu(cmd-frame-init.qinfo_new_addr_hi); iq_pa = (((uint64_t) pa_hi 32) | pa_lo); +trace_megasas_init_firmware((uint64_t)iq_pa); initq_size = sizeof(*initq); initq = cpu_physical_memory_map(iq_pa, initq_size, 0); if (!initq || initq_size != sizeof(*initq)) { +trace_megasas_initq_map_failed(cmd-index); s-event_count++; ret = MFI_STAT_MEMORY_NOT_AVAILABLE; goto out; } s-reply_queue_len = le32_to_cpu(initq-rq_entries) 0x; if (s-reply_queue_len s-fw_cmds) { +trace_megasas_initq_mismatch(s-reply_queue_len, s-fw_cmds); s-event_count++; ret = MFI_STAT_INVALID_PARAMETER; goto out; @@ -562,6 +591,9 @@ static int megasas_init_firmware(MegasasState *s, MegasasCmd *cmd)
[Qemu-devel] [PATCH 3/3] megasas: Add trace events
This patch add trace events to the megasas HBA emulation. Signed-off-by: Hannes Reinecke h...@suse.de --- hw/megasas.c | 297 -- trace-events | 79 2 files changed, 328 insertions(+), 48 deletions(-) diff --git a/hw/megasas.c b/hw/megasas.c index 42660c0..54abb93 100644 --- a/hw/megasas.c +++ b/hw/megasas.c @@ -26,6 +26,7 @@ #include scsi.h #include scsi-defs.h #include block_int.h +#include trace.h #include mfi.h @@ -221,6 +222,8 @@ static int megasas_map_sgl(MegasasCmd *cmd, union mfi_sgl *sgl) cmd-flags = le16_to_cpu(cmd-frame-header.flags); iov_count = cmd-frame-header.sge_count; if (iov_count MEGASAS_MAX_SGE) { +trace_megasas_iovec_sgl_overflow(cmd-index, iov_count, + MEGASAS_MAX_SGE); return iov_count; } qemu_sglist_init(cmd-qsg, iov_count); @@ -228,17 +231,25 @@ static int megasas_map_sgl(MegasasCmd *cmd, union mfi_sgl *sgl) dma_addr_t iov_pa, iov_size_p; if (!sgl) { +trace_megasas_iovec_sgl_underflow(cmd-index, i); goto unmap; } iov_pa = megasas_sgl_get_addr(cmd, sgl); iov_size_p = megasas_sgl_get_len(cmd, sgl); if (!iov_pa || !iov_size_p) { +trace_megasas_iovec_sgl_invalid(cmd-index, i, +iov_pa, iov_size_p); goto unmap; } qemu_sglist_add(cmd-qsg, iov_pa, iov_size_p); sgl = megasas_sgl_next(cmd, sgl); iov_size += (size_t)iov_size_p; } +if (cmd-iov_size iov_size) { +trace_megasas_iovec_overflow(cmd-index, iov_size, cmd-iov_size); +} else if (cmd-iov_size iov_size) { +trace_megasas_iovec_underflow(cmd-iov_size, iov_size, cmd-iov_size); +} cmd-iov_offset = 0; return 0; unmap: @@ -411,6 +422,7 @@ static MegasasCmd *megasas_next_frame(MegasasState *s, cmd = megasas_lookup_frame(s, frame); if (cmd) { +trace_megasas_qf_found(cmd-index, cmd-pa); return cmd; } index = s-reply_queue_head; @@ -423,6 +435,10 @@ static MegasasCmd *megasas_next_frame(MegasasState *s, index = megasas_next_index(s, index, s-fw_cmds); num++; } +if (!cmd) { +trace_megasas_qf_failed(frame); +} +trace_megasas_qf_new(index, cmd); return cmd; } @@ -443,6 +459,7 @@ static MegasasCmd *megasas_enqueue_frame(MegasasState *s, /* Map all possible frames */ cmd-frame = cpu_physical_memory_map(frame, frame_size_p, 0); if (frame_size_p != frame_size) { +trace_megasas_qf_map_failed(cmd-index, (unsigned long)frame); if (cmd-frame) { cpu_physical_memory_unmap(cmd-frame, frame_size_p, 0, 0); cmd-frame = NULL; @@ -460,6 +477,9 @@ static MegasasCmd *megasas_enqueue_frame(MegasasState *s, cmd-count = count; s-busy++; +trace_megasas_qf_enqueue(cmd-index, cmd-count, cmd-context, + s-reply_queue_head, s-busy); + return cmd; } @@ -485,6 +505,8 @@ static void megasas_complete_frame(MegasasState *s, uint64_t context) stl_le_phys(s-reply_queue_pa + queue_offset, context); } s-reply_queue_head = megasas_next_index(s, tail, s-fw_cmds); +trace_megasas_qf_complete(context, tail, queue_offset, + s-busy, s-doorbell); } if (megasas_intr_enabled(s)) { @@ -492,11 +514,15 @@ static void megasas_complete_frame(MegasasState *s, uint64_t context) s-doorbell++; if (s-doorbell == 1) { if (msix_enabled(s-dev)) { +trace_megasas_msix_raise(0); msix_notify(s-dev, 0); } else { +trace_megasas_irq_raise(); qemu_irq_raise(s-dev.irq[0]); } } +} else { +trace_megasas_qf_complete_noirq(context); } } @@ -534,15 +560,18 @@ static int megasas_init_firmware(MegasasState *s, MegasasCmd *cmd) pa_lo = le32_to_cpu(cmd-frame-init.qinfo_new_addr_lo); pa_hi = le32_to_cpu(cmd-frame-init.qinfo_new_addr_hi); iq_pa = (((uint64_t) pa_hi 32) | pa_lo); +trace_megasas_init_firmware((uint64_t)iq_pa); initq_size = sizeof(*initq); initq = cpu_physical_memory_map(iq_pa, initq_size, 0); if (!initq || initq_size != sizeof(*initq)) { +trace_megasas_initq_map_failed(cmd-index); s-event_count++; ret = MFI_STAT_MEMORY_NOT_AVAILABLE; goto out; } s-reply_queue_len = le32_to_cpu(initq-rq_entries) 0x; if (s-reply_queue_len s-fw_cmds) { +trace_megasas_initq_mismatch(s-reply_queue_len, s-fw_cmds); s-event_count++; ret = MFI_STAT_INVALID_PARAMETER; goto out; @@ -562,6 +591,9 @@ static int megasas_init_firmware(MegasasState *s, MegasasCmd
Re: [Qemu-devel] [PATCH 3/3] megasas: Add trace events
On 05/09/2012 11:52 AM, Hannes Reinecke wrote: This patch add trace events to the megasas HBA emulation. agraf@wolfberry-1:/home/agraf/git/qemu.megasas git pw am 157891 WARNING: line over 80 characters #233: FILE: hw/megasas.c:872: +offset + sizeof(struct mfi_pd_address)); WARNING: line over 80 characters #241: FILE: hw/megasas.c:896: +trace_megasas_dcmd_pd_get_list(cmd-index, num_pd_disks, max_pd_disks, offset); ERROR: space required after that ',' (ctx:VxV) #349: FILE: hw/megasas.c:1294: +dummy[0x00], dummy[0x01],dummy[0x02], dummy[0x03], ^ WARNING: line over 80 characters #433: FILE: hw/megasas.c:1332: +{ MFI_DCMD_CTRL_MFI_HOST_MEM_ALLOC, CTRL_HOST_MEM_ALLOC, megasas_dcmd_dummy }, WARNING: line over 80 characters #435: FILE: hw/megasas.c:1334: +{ MFI_DCMD_CTRL_GET_PROPERTIES, CTRL_GET_PROPERTIES, megasas_dcmd_get_properties }, WARNING: line over 80 characters #436: FILE: hw/megasas.c:1335: +{ MFI_DCMD_CTRL_SET_PROPERTIES, CTRL_SET_PROPERTIES, megasas_dcmd_set_properties }, WARNING: line over 80 characters #449: FILE: hw/megasas.c:1348: +{ MFI_DCMD_CTRL_BIOS_DATA_GET, CTRL_BIOS_DATA_GET, megasas_dcmd_get_bios_info }, WARNING: line over 80 characters #450: FILE: hw/megasas.c:1349: +{ MFI_DCMD_CTRL_FACTORY_DEFAULTS, CTRL_FACTORY_DEFAULTS, megasas_dcmd_dummy }, WARNING: line over 80 characters #451: FILE: hw/megasas.c:1350: +{ MFI_DCMD_CTRL_MFC_DEFAULTS_GET, CTRL_MFC_DEFAULTS_GET, megasas_mfc_get_defaults }, WARNING: line over 80 characters #452: FILE: hw/megasas.c:1351: +{ MFI_DCMD_CTRL_MFC_DEFAULTS_SET, CTRL_MFC_DEFAULTS_SET, megasas_dcmd_dummy }, total: 1 errors, 9 warnings, 792 lines checked Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. checkpatch failed, still apply? [y|N]
[Qemu-devel] [PATCH 3/3] megasas: Add trace events
This patch add trace events to the megasas HBA emulation. Signed-off-by: Hannes Reinecke h...@suse.de --- hw/megasas.c | 348 +- trace-events | 79 + 2 files changed, 377 insertions(+), 50 deletions(-) diff --git a/hw/megasas.c b/hw/megasas.c index 4178a4f..06ea61e 100644 --- a/hw/megasas.c +++ b/hw/megasas.c @@ -26,6 +26,7 @@ #include scsi.h #include scsi-defs.h #include block_int.h +#include trace.h #include mfi.h @@ -221,6 +222,8 @@ static int megasas_map_sgl(MegasasCmd *cmd, union mfi_sgl *sgl) cmd-flags = le16_to_cpu(cmd-frame-header.flags); iov_count = cmd-frame-header.sge_count; if (iov_count MEGASAS_MAX_SGE) { +trace_megasas_iovec_sgl_overflow(cmd-index, iov_count, + MEGASAS_MAX_SGE); return iov_count; } qemu_sglist_init(cmd-qsg, iov_count); @@ -228,17 +231,25 @@ static int megasas_map_sgl(MegasasCmd *cmd, union mfi_sgl *sgl) dma_addr_t iov_pa, iov_size_p; if (!sgl) { +trace_megasas_iovec_sgl_underflow(cmd-index, i); goto unmap; } iov_pa = megasas_sgl_get_addr(cmd, sgl); iov_size_p = megasas_sgl_get_len(cmd, sgl); if (!iov_pa || !iov_size_p) { +trace_megasas_iovec_sgl_invalid(cmd-index, i, +iov_pa, iov_size_p); goto unmap; } qemu_sglist_add(cmd-qsg, iov_pa, iov_size_p); sgl = megasas_sgl_next(cmd, sgl); iov_size += (size_t)iov_size_p; } +if (cmd-iov_size iov_size) { +trace_megasas_iovec_overflow(cmd-index, iov_size, cmd-iov_size); +} else if (cmd-iov_size iov_size) { +trace_megasas_iovec_underflow(cmd-iov_size, iov_size, cmd-iov_size); +} cmd-iov_offset = 0; return 0; unmap: @@ -411,6 +422,7 @@ static MegasasCmd *megasas_next_frame(MegasasState *s, cmd = megasas_lookup_frame(s, frame); if (cmd) { +trace_megasas_qf_found(cmd-index, cmd-pa); return cmd; } index = s-reply_queue_head; @@ -423,6 +435,10 @@ static MegasasCmd *megasas_next_frame(MegasasState *s, index = megasas_next_index(s, index, s-fw_cmds); num++; } +if (!cmd) { +trace_megasas_qf_failed(frame); +} +trace_megasas_qf_new(index, cmd); return cmd; } @@ -443,6 +459,7 @@ static MegasasCmd *megasas_enqueue_frame(MegasasState *s, /* Map all possible frames */ cmd-frame = cpu_physical_memory_map(frame, frame_size_p, 0); if (frame_size_p != frame_size) { +trace_megasas_qf_map_failed(cmd-index, (unsigned long)frame); if (cmd-frame) { cpu_physical_memory_unmap(cmd-frame, frame_size_p, 0, 0); cmd-frame = NULL; @@ -460,6 +477,9 @@ static MegasasCmd *megasas_enqueue_frame(MegasasState *s, cmd-count = count; s-busy++; +trace_megasas_qf_enqueue(cmd-index, cmd-count, cmd-context, + s-reply_queue_head, s-busy); + return cmd; } @@ -485,6 +505,8 @@ static void megasas_complete_frame(MegasasState *s, uint64_t context) stl_le_phys(s-reply_queue_pa + queue_offset, context); } s-reply_queue_head = megasas_next_index(s, tail, s-fw_cmds); +trace_megasas_qf_complete(context, tail, queue_offset, + s-busy, s-doorbell); } if (megasas_intr_enabled(s)) { @@ -492,11 +514,15 @@ static void megasas_complete_frame(MegasasState *s, uint64_t context) s-doorbell++; if (s-doorbell == 1) { if (msix_enabled(s-dev)) { +trace_megasas_msix_raise(0); msix_notify(s-dev, 0); } else { +trace_megasas_irq_raise(); qemu_irq_raise(s-dev.irq[0]); } } +} else { +trace_megasas_qf_complete_noirq(context); } } @@ -534,15 +560,18 @@ static int megasas_init_firmware(MegasasState *s, MegasasCmd *cmd) pa_lo = le32_to_cpu(cmd-frame-init.qinfo_new_addr_lo); pa_hi = le32_to_cpu(cmd-frame-init.qinfo_new_addr_hi); iq_pa = (((uint64_t) pa_hi 32) | pa_lo); +trace_megasas_init_firmware((uint64_t)iq_pa); initq_size = sizeof(*initq); initq = cpu_physical_memory_map(iq_pa, initq_size, 0); if (!initq || initq_size != sizeof(*initq)) { +trace_megasas_initq_map_failed(cmd-index); s-event_count++; ret = MFI_STAT_MEMORY_NOT_AVAILABLE; goto out; } s-reply_queue_len = le32_to_cpu(initq-rq_entries) 0x; if (s-reply_queue_len s-fw_cmds) { +trace_megasas_initq_mismatch(s-reply_queue_len, s-fw_cmds); s-event_count++; ret = MFI_STAT_INVALID_PARAMETER; goto out; @@ -562,6 +591,9 @@ static int megasas_init_firmware(MegasasState *s, MegasasCmd *cmd)