1/*
2 * The USB Monitor, inspired by Dave Harding's USBMon.
3 *
4 * Copyright (C) 2005 Pete Zaitcev (zaitcev@redhat.com)
5 */
6
7#ifndef __USB_MON_H
8#define __USB_MON_H
9
10#include <linux/list.h>
11#include <linux/slab.h>
12#include <linux/kref.h>
13/* #include <linux/usb.h> */	/* We use struct pointers only in this header */
14
15#define TAG "usbmon"
16
17struct mon_bus {
18	struct list_head bus_link;
19	spinlock_t lock;
20	struct usb_bus *u_bus;
21
22	int text_inited;
23	struct dentry *dent_s;		/* Debugging file */
24	struct dentry *dent_t;		/* Text interface file */
25	struct dentry *dent_u;		/* Second text interface file */
26
27	/* Ref */
28	int nreaders;			/* Under mon_lock AND mbus->lock */
29	struct list_head r_list;	/* Chain of readers (usually one) */
30	struct kref ref;		/* Under mon_lock */
31
32	/* Stats */
33	unsigned int cnt_events;
34	unsigned int cnt_text_lost;
35};
36
37/*
38 * An instance of a process which opened a file (but can fork later)
39 */
40struct mon_reader {
41	struct list_head r_link;
42	struct mon_bus *m_bus;
43	void *r_data;		/* Use container_of instead? */
44
45	void (*rnf_submit)(void *data, struct urb *urb);
46	void (*rnf_error)(void *data, struct urb *urb, int error);
47	void (*rnf_complete)(void *data, struct urb *urb);
48};
49
50void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r);
51void mon_reader_del(struct mon_bus *mbus, struct mon_reader *r);
52
53struct mon_bus *mon_bus_lookup(unsigned int num);
54
55int /*bool*/ mon_text_add(struct mon_bus *mbus, int busnum);
56void mon_text_del(struct mon_bus *mbus);
57// void mon_bin_add(struct mon_bus *);
58
59int __init mon_text_init(void);
60void mon_text_exit(void);
61int __init mon_bin_init(void);
62void mon_bin_exit(void);
63
64extern char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len);
65
66struct mon_reader_bin;
67extern void mon_dmapeek_vec(const struct mon_reader_bin *rp,
68    unsigned int offset, dma_addr_t dma_addr, unsigned int len);
69extern unsigned int mon_copy_to_buff(const struct mon_reader_bin *rp,
70    unsigned int offset, const unsigned char *from, unsigned int len);
71
72/*
73 */
74extern struct mutex mon_lock;
75
76extern const struct file_operations mon_fops_stat;
77
78extern struct mon_bus mon_bus0;		/* Only for redundant checks */
79
80#endif /* __USB_MON_H */
81