Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * The USB Monitor, inspired by Dave Harding's USBMon. |
Pete Zaitcev | da5ca00 | 2005-08-16 15:16:46 -0700 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2005 Pete Zaitcev (zaitcev@redhat.com) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| 17 | struct 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; |
| 23 | |
| 24 | /* Ref */ |
| 25 | int nreaders; /* Under mon_lock AND mbus->lock */ |
| 26 | struct list_head r_list; /* Chain of readers (usually one) */ |
| 27 | struct kref ref; /* Under mon_lock */ |
| 28 | |
| 29 | /* Stats */ |
Pete Zaitcev | 5b1c674 | 2006-06-09 20:10:10 -0700 | [diff] [blame] | 30 | unsigned int cnt_events; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | unsigned int cnt_text_lost; |
| 32 | }; |
| 33 | |
| 34 | /* |
| 35 | * An instance of a process which opened a file (but can fork later) |
| 36 | */ |
| 37 | struct mon_reader { |
| 38 | struct list_head r_link; |
| 39 | struct mon_bus *m_bus; |
| 40 | void *r_data; /* Use container_of instead? */ |
| 41 | |
| 42 | void (*rnf_submit)(void *data, struct urb *urb); |
Pete Zaitcev | 12e72fe | 2006-06-09 22:03:32 -0700 | [diff] [blame] | 43 | void (*rnf_error)(void *data, struct urb *urb, int error); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | void (*rnf_complete)(void *data, struct urb *urb); |
| 45 | }; |
| 46 | |
| 47 | void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r); |
| 48 | void mon_reader_del(struct mon_bus *mbus, struct mon_reader *r); |
| 49 | |
Pete Zaitcev | 0256839 | 2005-08-15 16:53:57 -0700 | [diff] [blame] | 50 | /* |
| 51 | */ |
| 52 | extern char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len); |
| 53 | |
Arjan van de Ven | 4186ecf | 2006-01-11 15:55:29 +0100 | [diff] [blame] | 54 | extern struct mutex mon_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | |
Luiz Fernando N. Capitulino | 066202d | 2006-08-05 20:37:11 -0300 | [diff] [blame^] | 56 | extern const struct file_operations mon_fops_text; |
| 57 | extern const struct file_operations mon_fops_stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
| 59 | #endif /* __USB_MON_H */ |