0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef __PKTCDVD_H
0013 #define __PKTCDVD_H
0014
0015 #include <linux/blkdev.h>
0016 #include <linux/completion.h>
0017 #include <linux/cdrom.h>
0018 #include <linux/kobject.h>
0019 #include <linux/sysfs.h>
0020 #include <linux/mempool.h>
0021 #include <uapi/linux/pktcdvd.h>
0022
0023
0024 #define PKT_WRITE_CONGESTION_ON 10000
0025 #define PKT_WRITE_CONGESTION_OFF 9000
0026
0027
0028 struct packet_settings
0029 {
0030 __u32 size;
0031 __u8 fp;
0032 __u8 link_loss;
0033
0034 __u8 write_type;
0035 __u8 track_mode;
0036 __u8 block_mode;
0037 };
0038
0039
0040
0041
0042 struct packet_stats
0043 {
0044 unsigned long pkt_started;
0045 unsigned long pkt_ended;
0046 unsigned long secs_w;
0047 unsigned long secs_rg;
0048 unsigned long secs_r;
0049 };
0050
0051 struct packet_cdrw
0052 {
0053 struct list_head pkt_free_list;
0054 struct list_head pkt_active_list;
0055 spinlock_t active_list_lock;
0056 struct task_struct *thread;
0057 atomic_t pending_bios;
0058 };
0059
0060
0061
0062
0063
0064 #define HI_SPEED_SWITCH 512
0065
0066 struct packet_iosched
0067 {
0068 atomic_t attention;
0069 int writing;
0070 spinlock_t lock;
0071 struct bio_list read_queue;
0072 struct bio_list write_queue;
0073 sector_t last_write;
0074 int successive_reads;
0075 };
0076
0077
0078
0079
0080 #if (PAGE_SIZE % CD_FRAMESIZE) != 0
0081 #error "PAGE_SIZE must be a multiple of CD_FRAMESIZE"
0082 #endif
0083 #define PACKET_MAX_SIZE 128
0084 #define FRAMES_PER_PAGE (PAGE_SIZE / CD_FRAMESIZE)
0085 #define PACKET_MAX_SECTORS (PACKET_MAX_SIZE * CD_FRAMESIZE >> 9)
0086
0087 enum packet_data_state {
0088 PACKET_IDLE_STATE,
0089 PACKET_WAITING_STATE,
0090
0091
0092 PACKET_READ_WAIT_STATE,
0093 PACKET_WRITE_WAIT_STATE,
0094 PACKET_RECOVERY_STATE,
0095 PACKET_FINISHED_STATE,
0096
0097 PACKET_NUM_STATES
0098 };
0099
0100
0101
0102
0103 struct pktcdvd_device;
0104
0105 struct packet_data
0106 {
0107 struct list_head list;
0108
0109 spinlock_t lock;
0110
0111
0112 struct bio_list orig_bios;
0113
0114 int write_size;
0115
0116
0117 struct bio *w_bio;
0118
0119
0120 sector_t sector;
0121 int frames;
0122
0123 enum packet_data_state state;
0124 atomic_t run_sm;
0125
0126 long sleep_time;
0127
0128
0129 atomic_t io_wait;
0130 atomic_t io_errors;
0131
0132 struct bio *r_bios[PACKET_MAX_SIZE];
0133 struct page *pages[PACKET_MAX_SIZE / FRAMES_PER_PAGE];
0134
0135 int cache_valid;
0136
0137
0138
0139 int id;
0140 struct pktcdvd_device *pd;
0141 };
0142
0143 struct pkt_rb_node {
0144 struct rb_node rb_node;
0145 struct bio *bio;
0146 };
0147
0148 struct packet_stacked_data
0149 {
0150 struct bio *bio;
0151 struct pktcdvd_device *pd;
0152 };
0153 #define PSD_POOL_SIZE 64
0154
0155 struct pktcdvd_device
0156 {
0157 struct block_device *bdev;
0158 dev_t pkt_dev;
0159 char name[20];
0160 struct packet_settings settings;
0161 struct packet_stats stats;
0162 int refcnt;
0163 int write_speed;
0164 int read_speed;
0165 unsigned long offset;
0166 __u8 mode_offset;
0167 __u8 type;
0168 unsigned long flags;
0169 __u16 mmc3_profile;
0170 __u32 nwa;
0171 __u32 lra;
0172 struct packet_cdrw cdrw;
0173 wait_queue_head_t wqueue;
0174
0175 spinlock_t lock;
0176 struct rb_root bio_queue;
0177 int bio_queue_size;
0178 bool congested;
0179
0180 sector_t current_sector;
0181 atomic_t scan_queue;
0182
0183 mempool_t rb_pool;
0184
0185 struct packet_iosched iosched;
0186 struct gendisk *disk;
0187
0188 int write_congestion_off;
0189 int write_congestion_on;
0190
0191 struct device *dev;
0192
0193 struct dentry *dfs_d_root;
0194 struct dentry *dfs_f_info;
0195 };
0196
0197 #endif