blob: ab9d02d5df77a448c0c829c42b5b3633fbdfc054 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * The USB Monitor, inspired by Dave Harding's USBMon.
Pete Zaitcevda5ca002005-08-16 15:16:46 -07003 *
4 * Copyright (C) 2005 Pete Zaitcev (zaitcev@redhat.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 */
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 dentry *dent_s; /* Debugging file */
21 struct dentry *dent_t; /* Text interface file */
22 struct usb_bus *u_bus;
Alan Stern4d6cd482006-08-30 11:35:21 -040023 int uses_dma;
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25 /* Ref */
26 int nreaders; /* Under mon_lock AND mbus->lock */
27 struct list_head r_list; /* Chain of readers (usually one) */
28 struct kref ref; /* Under mon_lock */
29
30 /* Stats */
Pete Zaitcev5b1c6742006-06-09 20:10:10 -070031 unsigned int cnt_events;
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 unsigned int cnt_text_lost;
33};
34
35/*
36 * An instance of a process which opened a file (but can fork later)
37 */
38struct mon_reader {
39 struct list_head r_link;
40 struct mon_bus *m_bus;
41 void *r_data; /* Use container_of instead? */
42
43 void (*rnf_submit)(void *data, struct urb *urb);
Pete Zaitcev12e72fe2006-06-09 22:03:32 -070044 void (*rnf_error)(void *data, struct urb *urb, int error);
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 void (*rnf_complete)(void *data, struct urb *urb);
46};
47
48void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r);
49void mon_reader_del(struct mon_bus *mbus, struct mon_reader *r);
50
Pete Zaitcev02568392005-08-15 16:53:57 -070051/*
52 */
53extern char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len);
54
Arjan van de Ven4186ecf2006-01-11 15:55:29 +010055extern struct mutex mon_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Luiz Fernando N. Capitulino066202d2006-08-05 20:37:11 -030057extern const struct file_operations mon_fops_text;
58extern const struct file_operations mon_fops_stat;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60#endif /* __USB_MON_H */