v2.4.10.4 -> v2.4.10.5
[linux-flexiantxendom0-3.2.10.git] / drivers / usb / hpusbscsi.h
1 /* Header file for the hpusbscsi driver */
2 /* (C) Copyright 2001 Oliver Neukum */
3 /* sponsored by the Linux Usb Project */
4 /* large parts based on or taken from code by John Fremlin and Matt Dharm */
5 /* this file is licensed under the GPL */
6
7 typedef void (*usb_urb_callback) (struct urb *);
8 typedef void (*scsi_callback)(Scsi_Cmnd *);
9
10 struct hpusbscsi
11 {
12         struct list_head lh;
13         struct usb_device *dev; /* NULL indicates unplugged device */
14         int ep_out;
15         int ep_in;
16         int ep_int;
17         int interrupt_interval;
18
19         struct Scsi_Host *host;
20         Scsi_Host_Template ctempl;
21         int number;
22        scsi_callback scallback;
23        Scsi_Cmnd *srb;
24
25         int use_count;
26         wait_queue_head_t pending;
27         wait_queue_head_t deathrow;
28
29         struct urb dataurb;
30         struct urb controlurb;
31         int fragment;
32
33         int state;
34         int current_data_pipe;
35
36         u8 scsi_state_byte;
37 };
38
39 #define SCSI_ERR_MASK ~0x3fu
40
41 static const unsigned char scsi_command_direction[256/8] = {
42         0x28, 0x81, 0x14, 0x14, 0x20, 0x01, 0x90, 0x77,
43         0x0C, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
44         0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01,
45         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
46 };
47
48 #define DIRECTION_IS_IN(x) ((scsi_command_direction[x>>3] >> (x & 7)) & 1)
49
50 static int hpusbscsi_scsi_detect (struct SHT * sht);
51 static void simple_command_callback(struct urb *u);
52 static void scatter_gather_callback(struct urb *u);
53 static void simple_payload_callback (struct urb *u);
54 static void  control_interrupt_callback (struct urb *u);
55 static void simple_done (struct urb *u);
56 static int hpusbscsi_scsi_queuecommand (Scsi_Cmnd *srb, scsi_callback callback);
57 static int hpusbscsi_scsi_host_reset (Scsi_Cmnd *srb);
58 static int hpusbscsi_scsi_abort (Scsi_Cmnd *srb);
59
60 static Scsi_Host_Template hpusbscsi_scsi_host_template = {
61         name:           "hpusbscsi",
62         detect:         hpusbscsi_scsi_detect,
63 //      release:        hpusbscsi_scsi_release,
64         queuecommand:   hpusbscsi_scsi_queuecommand,
65
66         eh_abort_handler:       hpusbscsi_scsi_abort,
67         eh_host_reset_handler:  hpusbscsi_scsi_host_reset,
68
69         sg_tablesize:           SG_ALL,
70         can_queue:              1,
71         this_id:                -1,
72         cmd_per_lun:            1,
73         present:                0,
74         unchecked_isa_dma:      FALSE,
75         use_clustering:         TRUE,
76         use_new_eh_code:        TRUE,
77         emulated:               TRUE
78 };
79
80 /* defines for internal driver state */
81 #define HP_STATE_FREE                 0  /*ready for next request */
82 #define HP_STATE_BEGINNING      1  /*command being transfered */
83 #define HP_STATE_WORKING         2  /* data transfer stage */
84 #define HP_STATE_ERROR             3  /* error has been reported */
85 #define HP_STATE_WAIT                 4  /* waiting for status transfer */
86 #define HP_STATE_PREMATURE              5 /* status prematurely reported */
87
88