2 * The USB Monitor, inspired by Dave Harding's USBMon.
4 * Copyright (C) 2005 Pete Zaitcev (zaitcev@redhat.com)
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 */
18 struct list_head bus_link
;
20 struct usb_bus
*u_bus
;
24 struct dentry
*dent_s
; /* Debugging file */
25 struct dentry
*dent_t
; /* Text interface file */
26 struct dentry
*dent_u
; /* Second text interface file */
27 struct device
*classdev
; /* Device in usbmon class */
30 int nreaders
; /* Under mon_lock AND mbus->lock */
31 struct list_head r_list
; /* Chain of readers (usually one) */
32 struct kref ref
; /* Under mon_lock */
35 unsigned int cnt_events
;
36 unsigned int cnt_text_lost
;
40 * An instance of a process which opened a file (but can fork later)
43 struct list_head r_link
;
44 struct mon_bus
*m_bus
;
45 void *r_data
; /* Use container_of instead? */
47 void (*rnf_submit
)(void *data
, struct urb
*urb
);
48 void (*rnf_error
)(void *data
, struct urb
*urb
, int error
);
49 void (*rnf_complete
)(void *data
, struct urb
*urb
, int status
);
52 void mon_reader_add(struct mon_bus
*mbus
, struct mon_reader
*r
);
53 void mon_reader_del(struct mon_bus
*mbus
, struct mon_reader
*r
);
55 struct mon_bus
*mon_bus_lookup(unsigned int num
);
57 int /*bool*/ mon_text_add(struct mon_bus
*mbus
, const struct usb_bus
*ubus
);
58 void mon_text_del(struct mon_bus
*mbus
);
59 int /*bool*/ mon_bin_add(struct mon_bus
*mbus
, const struct usb_bus
*ubus
);
60 void mon_bin_del(struct mon_bus
*mbus
);
62 int __init
mon_text_init(void);
63 void mon_text_exit(void);
64 int __init
mon_bin_init(void);
65 void mon_bin_exit(void);
70 * XXX The vectored side needs a serious re-thinking. Abstracting vectors,
71 * like in Paolo's original patch, produces a double pkmap. We need an idea.
73 extern char mon_dmapeek(unsigned char *dst
, dma_addr_t dma_addr
, int len
);
75 struct mon_reader_bin
;
76 extern void mon_dmapeek_vec(const struct mon_reader_bin
*rp
,
77 unsigned int offset
, dma_addr_t dma_addr
, unsigned int len
);
78 extern unsigned int mon_copy_to_buff(const struct mon_reader_bin
*rp
,
79 unsigned int offset
, const unsigned char *from
, unsigned int len
);
83 extern struct mutex mon_lock
;
85 extern const struct file_operations mon_fops_stat
;
87 extern struct mon_bus mon_bus0
; /* Only for redundant checks */
89 #endif /* __USB_MON_H */