1
2
3
4
5
6
7
8
9
10
11
12#ifndef __PKTCDVD_H
13#define __PKTCDVD_H
14
15#include <linux/types.h>
16
17
18
19
20#define PACKET_DEBUG 1
21
22#define MAX_WRITERS 8
23
24#define PKT_RB_POOL_SIZE 512
25
26
27
28
29#define PACKET_WAIT_TIME (HZ * 5 / 1000)
30
31
32
33
34
35
36#if defined(CONFIG_CDROM_PKTCDVD_WCACHE)
37#define USE_WCACHING 1
38#else
39#define USE_WCACHING 0
40#endif
41
42
43
44
45
46
47
48
49#define PACKET_CDR 1
50#define PACKET_CDRW 2
51#define PACKET_DVDR 3
52#define PACKET_DVDRW 4
53
54
55
56
57#define PACKET_WRITABLE 1
58#define PACKET_NWA_VALID 2
59#define PACKET_LRA_VALID 3
60#define PACKET_MERGE_SEGS 4
61
62
63
64
65
66#define PACKET_DISC_EMPTY 0
67#define PACKET_DISC_INCOMPLETE 1
68#define PACKET_DISC_COMPLETE 2
69#define PACKET_DISC_OTHER 3
70
71
72
73
74#define PACKET_MODE1 1
75#define PACKET_MODE2 2
76#define PACKET_BLOCK_MODE1 8
77#define PACKET_BLOCK_MODE2 10
78
79
80
81
82#define PACKET_SESSION_EMPTY 0
83#define PACKET_SESSION_INCOMPLETE 1
84#define PACKET_SESSION_RESERVED 2
85#define PACKET_SESSION_COMPLETE 3
86
87#define PACKET_MCN "4a656e734178626f65323030300000"
88
89#undef PACKET_USE_LS
90
91#define PKT_CTRL_CMD_SETUP 0
92#define PKT_CTRL_CMD_TEARDOWN 1
93#define PKT_CTRL_CMD_STATUS 2
94
95struct pkt_ctrl_command {
96 __u32 command;
97 __u32 dev_index;
98 __u32 dev;
99 __u32 pkt_dev;
100 __u32 num_devices;
101 __u32 padding;
102};
103
104
105
106
107#define PACKET_IOCTL_MAGIC ('X')
108#define PACKET_CTRL_CMD _IOWR(PACKET_IOCTL_MAGIC, 1, struct pkt_ctrl_command)
109
110#ifdef __KERNEL__
111#include <linux/blkdev.h>
112#include <linux/completion.h>
113#include <linux/cdrom.h>
114#include <linux/kobject.h>
115#include <linux/sysfs.h>
116#include <linux/mempool.h>
117
118
119#define PKT_WRITE_CONGESTION_ON 10000
120#define PKT_WRITE_CONGESTION_OFF 9000
121
122
123struct packet_settings
124{
125 __u32 size;
126 __u8 fp;
127 __u8 link_loss;
128
129 __u8 write_type;
130 __u8 track_mode;
131 __u8 block_mode;
132};
133
134
135
136
137struct packet_stats
138{
139 unsigned long pkt_started;
140 unsigned long pkt_ended;
141 unsigned long secs_w;
142 unsigned long secs_rg;
143 unsigned long secs_r;
144};
145
146struct packet_cdrw
147{
148 struct list_head pkt_free_list;
149 struct list_head pkt_active_list;
150 spinlock_t active_list_lock;
151 struct task_struct *thread;
152 atomic_t pending_bios;
153};
154
155
156
157
158
159#define HI_SPEED_SWITCH 512
160
161struct packet_iosched
162{
163 atomic_t attention;
164 int writing;
165 spinlock_t lock;
166 struct bio_list read_queue;
167 struct bio_list write_queue;
168 sector_t last_write;
169 int successive_reads;
170};
171
172
173
174
175#if (PAGE_SIZE % CD_FRAMESIZE) != 0
176#error "PAGE_SIZE must be a multiple of CD_FRAMESIZE"
177#endif
178#define PACKET_MAX_SIZE 128
179#define FRAMES_PER_PAGE (PAGE_SIZE / CD_FRAMESIZE)
180#define PACKET_MAX_SECTORS (PACKET_MAX_SIZE * CD_FRAMESIZE >> 9)
181
182enum packet_data_state {
183 PACKET_IDLE_STATE,
184 PACKET_WAITING_STATE,
185
186
187 PACKET_READ_WAIT_STATE,
188 PACKET_WRITE_WAIT_STATE,
189 PACKET_RECOVERY_STATE,
190 PACKET_FINISHED_STATE,
191
192 PACKET_NUM_STATES
193};
194
195
196
197
198struct pktcdvd_device;
199
200struct packet_data
201{
202 struct list_head list;
203
204 spinlock_t lock;
205
206
207 struct bio_list orig_bios;
208
209 int write_size;
210
211
212 struct bio *w_bio;
213
214
215 sector_t sector;
216 int frames;
217
218 enum packet_data_state state;
219 atomic_t run_sm;
220
221 long sleep_time;
222
223
224 atomic_t io_wait;
225 atomic_t io_errors;
226
227 struct bio *r_bios[PACKET_MAX_SIZE];
228 struct page *pages[PACKET_MAX_SIZE / FRAMES_PER_PAGE];
229
230 int cache_valid;
231
232
233
234 int id;
235 struct pktcdvd_device *pd;
236};
237
238struct pkt_rb_node {
239 struct rb_node rb_node;
240 struct bio *bio;
241};
242
243struct packet_stacked_data
244{
245 struct bio *bio;
246 struct pktcdvd_device *pd;
247};
248#define PSD_POOL_SIZE 64
249
250struct pktcdvd_kobj
251{
252 struct kobject kobj;
253 struct pktcdvd_device *pd;
254};
255#define to_pktcdvdkobj(_k) \
256 ((struct pktcdvd_kobj*)container_of(_k,struct pktcdvd_kobj,kobj))
257
258struct pktcdvd_device
259{
260 struct block_device *bdev;
261 dev_t pkt_dev;
262 char name[20];
263 struct packet_settings settings;
264 struct packet_stats stats;
265 int refcnt;
266 int write_speed;
267 int read_speed;
268 unsigned long offset;
269 __u8 mode_offset;
270 __u8 type;
271 unsigned long flags;
272 __u16 mmc3_profile;
273 __u32 nwa;
274 __u32 lra;
275 struct packet_cdrw cdrw;
276 wait_queue_head_t wqueue;
277
278 spinlock_t lock;
279 struct rb_root bio_queue;
280 int bio_queue_size;
281 sector_t current_sector;
282 atomic_t scan_queue;
283
284 mempool_t *rb_pool;
285
286 struct packet_iosched iosched;
287 struct gendisk *disk;
288
289 int write_congestion_off;
290 int write_congestion_on;
291
292 struct device *dev;
293 struct pktcdvd_kobj *kobj_stat;
294 struct pktcdvd_kobj *kobj_wqueue;
295
296 struct dentry *dfs_d_root;
297 struct dentry *dfs_f_info;
298};
299
300#endif
301
302#endif
303