netfilter: nf_conntrack: fix hash resizing with namespaces
[safe/jmp/linux-2.6] / include / linux / mmiotrace.h
index cb24782..97491f7 100644 (file)
-#ifndef MMIOTRACE_H
-#define MMIOTRACE_H
-
-#include <asm/types.h>
-
-#define MMIO_VERSION 0x04
-
-/* mm_io_header.type */
-#define MMIO_OPCODE_MASK 0xff
-#define MMIO_OPCODE_SHIFT 0
-#define MMIO_WIDTH_MASK 0xff00
-#define MMIO_WIDTH_SHIFT 8
-#define MMIO_MAGIC (0x6f000000 | (MMIO_VERSION<<16))
-#define MMIO_MAGIC_MASK 0xffff0000
-
-enum mm_io_opcode {          /* payload type: */
-       MMIO_READ = 0x1,     /* struct mm_io_rw */
-       MMIO_WRITE = 0x2,    /* struct mm_io_rw */
-       MMIO_PROBE = 0x3,    /* struct mm_io_map */
-       MMIO_UNPROBE = 0x4,  /* struct mm_io_map */
-       MMIO_MARKER = 0x5,   /* raw char data */
-       MMIO_UNKNOWN_OP = 0x6, /* struct mm_io_rw */
-};
+#ifndef _LINUX_MMIOTRACE_H
+#define _LINUX_MMIOTRACE_H
 
-struct mm_io_header {
-       __u32 type;
-       __u32 sec;      /* timestamp */
-       __u32 nsec;
-       __u32 pid;      /* PID of the process, or 0 for kernel core */
-       __u16 data_len; /* length of the following payload */
-};
+#include <linux/types.h>
+#include <linux/list.h>
 
-struct mm_io_rw {
-       __u64 address; /* virtual address of register */
-       __u64 value;
-       __u64 pc;      /* optional program counter */
-};
+struct kmmio_probe;
+struct pt_regs;
 
-struct mm_io_map {
-       __u64 phys;  /* base address in PCI space */
-       __u64 addr;  /* base virtual address */
-       __u64 len;   /* mapping size */
-       __u64 pc;    /* optional program counter */
+typedef void (*kmmio_pre_handler_t)(struct kmmio_probe *,
+                               struct pt_regs *, unsigned long addr);
+typedef void (*kmmio_post_handler_t)(struct kmmio_probe *,
+                               unsigned long condition, struct pt_regs *);
+
+struct kmmio_probe {
+       /* kmmio internal list: */
+       struct list_head        list;
+       /* start location of the probe point: */
+       unsigned long           addr;
+       /* length of the probe region: */
+       unsigned long           len;
+       /* Called before addr is executed: */
+       kmmio_pre_handler_t     pre_handler;
+       /* Called after addr is executed: */
+       kmmio_post_handler_t    post_handler;
+       void                    *private;
 };
 
+extern unsigned int kmmio_count;
+
+extern int register_kmmio_probe(struct kmmio_probe *p);
+extern void unregister_kmmio_probe(struct kmmio_probe *p);
+extern int kmmio_init(void);
+extern void kmmio_cleanup(void);
+
+#ifdef CONFIG_MMIOTRACE
+/* kmmio is active by some kmmio_probes? */
+static inline int is_kmmio_active(void)
+{
+       return kmmio_count;
+}
+
+/* Called from page fault handler. */
+extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
+
+/* Called from ioremap.c */
+extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
+                                                       void __iomem *addr);
+extern void mmiotrace_iounmap(volatile void __iomem *addr);
+
+/* For anyone to insert markers. Remember trailing newline. */
+extern int mmiotrace_printk(const char *fmt, ...)
+                               __attribute__ ((format (printf, 1, 2)));
+#else /* !CONFIG_MMIOTRACE: */
+static inline int is_kmmio_active(void)
+{
+       return 0;
+}
 
-/*
- * These structures are used to allow a single relay_write()
- * call to write a full packet.
- */
+static inline int kmmio_handler(struct pt_regs *regs, unsigned long addr)
+{
+       return 0;
+}
 
-struct mm_io_header_rw {
-       struct mm_io_header header;
-       struct mm_io_rw rw;
-} __attribute__((packed));
+static inline void mmiotrace_ioremap(resource_size_t offset,
+                                       unsigned long size, void __iomem *addr)
+{
+}
+
+static inline void mmiotrace_iounmap(volatile void __iomem *addr)
+{
+}
+
+static inline int mmiotrace_printk(const char *fmt, ...)
+                               __attribute__ ((format (printf, 1, 0)));
+
+static inline int mmiotrace_printk(const char *fmt, ...)
+{
+       return 0;
+}
+#endif /* CONFIG_MMIOTRACE */
+
+enum mm_io_opcode {
+       MMIO_READ       = 0x1,  /* struct mmiotrace_rw */
+       MMIO_WRITE      = 0x2,  /* struct mmiotrace_rw */
+       MMIO_PROBE      = 0x3,  /* struct mmiotrace_map */
+       MMIO_UNPROBE    = 0x4,  /* struct mmiotrace_map */
+       MMIO_UNKNOWN_OP = 0x5,  /* struct mmiotrace_rw */
+};
+
+struct mmiotrace_rw {
+       resource_size_t phys;   /* PCI address of register */
+       unsigned long   value;
+       unsigned long   pc;     /* optional program counter */
+       int             map_id;
+       unsigned char   opcode; /* one of MMIO_{READ,WRITE,UNKNOWN_OP} */
+       unsigned char   width;  /* size of register access in bytes */
+};
+
+struct mmiotrace_map {
+       resource_size_t phys;   /* base address in PCI space */
+       unsigned long   virt;   /* base virtual address */
+       unsigned long   len;    /* mapping size */
+       int             map_id;
+       unsigned char   opcode; /* MMIO_PROBE or MMIO_UNPROBE */
+};
 
-struct mm_io_header_map {
-       struct mm_io_header header;
-       struct mm_io_map map;
-} __attribute__((packed));
+/* in kernel/trace/trace_mmiotrace.c */
+extern void enable_mmiotrace(void);
+extern void disable_mmiotrace(void);
+extern void mmio_trace_rw(struct mmiotrace_rw *rw);
+extern void mmio_trace_mapping(struct mmiotrace_map *map);
+extern int mmio_trace_printk(const char *fmt, va_list args);
 
-#endif /* MMIOTRACE_H */
+#endif /* _LINUX_MMIOTRACE_H */