1
2
3
4
5
6
7
8
9
10
11
12 #ifndef __PKTCDVD_H
13 #define __PKTCDVD_H
14
15 #include <linux/blkdev.h>
16 #include <linux/completion.h>
17 #include <linux/cdrom.h>
18 #include <linux/kobject.h>
19 #include <linux/sysfs.h>
20 #include <linux/mempool.h>
21 #include <uapi/linux/pktcdvd.h>
22
23
24 #define PKT_WRITE_CONGESTION_ON 10000
25 #define PKT_WRITE_CONGESTION_OFF 9000
26
27
28 struct packet_settings
29 {
30 __u32 size;
31 __u8 fp;
32 __u8 link_loss;
33
34 __u8 write_type;
35 __u8 track_mode;
36 __u8 block_mode;
37 };
38
39
40
41
42 struct packet_stats
43 {
44 unsigned long pkt_started;
45 unsigned long pkt_ended;
46 unsigned long secs_w;
47 unsigned long secs_rg;
48 unsigned long secs_r;
49 };
50
51 struct packet_cdrw
52 {
53 struct list_head pkt_free_list;
54 struct list_head pkt_active_list;
55 spinlock_t active_list_lock;
56 struct task_struct *thread;
57 atomic_t pending_bios;
58 };
59
60
61
62
63
64 #define HI_SPEED_SWITCH 512
65
66 struct packet_iosched
67 {
68 atomic_t attention;
69 int writing;
70 spinlock_t lock;
71 struct bio_list read_queue;
72 struct bio_list write_queue;
73 sector_t last_write;
74 int successive_reads;
75 };
76
77
78
79
80 #if (PAGE_SIZE % CD_FRAMESIZE) != 0
81 #error "PAGE_SIZE must be a multiple of CD_FRAMESIZE"
82 #endif
83 #define PACKET_MAX_SIZE 128
84 #define FRAMES_PER_PAGE (PAGE_SIZE / CD_FRAMESIZE)
85 #define PACKET_MAX_SECTORS (PACKET_MAX_SIZE * CD_FRAMESIZE >> 9)
86
87 enum packet_data_state {
88 PACKET_IDLE_STATE,
89 PACKET_WAITING_STATE,
90
91
92 PACKET_READ_WAIT_STATE,
93 PACKET_WRITE_WAIT_STATE,
94 PACKET_RECOVERY_STATE,
95 PACKET_FINISHED_STATE,
96
97 PACKET_NUM_STATES
98 };
99
100
101
102
103 struct pktcdvd_device;
104
105 struct packet_data
106 {
107 struct list_head list;
108
109 spinlock_t lock;
110
111
112 struct bio_list orig_bios;
113
114 int write_size;
115
116
117 struct bio *w_bio;
118
119
120 sector_t sector;
121 int frames;
122
123 enum packet_data_state state;
124 atomic_t run_sm;
125
126 long sleep_time;
127
128
129 atomic_t io_wait;
130 atomic_t io_errors;
131
132 struct bio *r_bios[PACKET_MAX_SIZE];
133 struct page *pages[PACKET_MAX_SIZE / FRAMES_PER_PAGE];
134
135 int cache_valid;
136
137
138
139 int id;
140 struct pktcdvd_device *pd;
141 };
142
143 struct pkt_rb_node {
144 struct rb_node rb_node;
145 struct bio *bio;
146 };
147
148 struct packet_stacked_data
149 {
150 struct bio *bio;
151 struct pktcdvd_device *pd;
152 };
153 #define PSD_POOL_SIZE 64
154
155 struct pktcdvd_kobj
156 {
157 struct kobject kobj;
158 struct pktcdvd_device *pd;
159 };
160 #define to_pktcdvdkobj(_k) \
161 ((struct pktcdvd_kobj*)container_of(_k,struct pktcdvd_kobj,kobj))
162
163 struct pktcdvd_device
164 {
165 struct block_device *bdev;
166 dev_t pkt_dev;
167 char name[20];
168 struct packet_settings settings;
169 struct packet_stats stats;
170 int refcnt;
171 int write_speed;
172 int read_speed;
173 unsigned long offset;
174 __u8 mode_offset;
175 __u8 type;
176 unsigned long flags;
177 __u16 mmc3_profile;
178 __u32 nwa;
179 __u32 lra;
180 struct packet_cdrw cdrw;
181 wait_queue_head_t wqueue;
182
183 spinlock_t lock;
184 struct rb_root bio_queue;
185 int bio_queue_size;
186 sector_t current_sector;
187 atomic_t scan_queue;
188
189 mempool_t rb_pool;
190
191 struct packet_iosched iosched;
192 struct gendisk *disk;
193
194 int write_congestion_off;
195 int write_congestion_on;
196
197 struct device *dev;
198 struct pktcdvd_kobj *kobj_stat;
199 struct pktcdvd_kobj *kobj_wqueue;
200
201 struct dentry *dfs_d_root;
202 struct dentry *dfs_f_info;
203 };
204
205 #endif