Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _SCSI_SCSI_CMND_H |
| 2 | #define _SCSI_SCSI_CMND_H |
| 3 | |
| 4 | #include <linux/dma-mapping.h> |
| 5 | #include <linux/list.h> |
| 6 | #include <linux/types.h> |
Tim Schmielau | 4e57b68 | 2005-10-30 15:03:48 -0800 | [diff] [blame] | 7 | #include <linux/timer.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | |
| 9 | struct request; |
| 10 | struct scatterlist; |
| 11 | struct scsi_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
| 13 | |
| 14 | /* embedded in scsi_cmnd */ |
| 15 | struct scsi_pointer { |
| 16 | char *ptr; /* data pointer */ |
| 17 | int this_residual; /* left in this buffer */ |
| 18 | struct scatterlist *buffer; /* which buffer */ |
| 19 | int buffers_residual; /* how many buffers left */ |
| 20 | |
| 21 | dma_addr_t dma_handle; |
| 22 | |
| 23 | volatile int Status; |
| 24 | volatile int Message; |
| 25 | volatile int have_data_in; |
| 26 | volatile int sent_command; |
| 27 | volatile int phase; |
| 28 | }; |
| 29 | |
| 30 | struct scsi_cmnd { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | struct scsi_device *device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | struct list_head list; /* scsi_cmnd participates in queue lists */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | struct list_head eh_entry; /* entry for the host eh_cmd_q */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | int eh_eflags; /* Used by error handlr */ |
| 35 | void (*done) (struct scsi_cmnd *); /* Mid-level done function */ |
| 36 | |
| 37 | /* |
| c6295cd | 2005-04-03 14:59:11 -0500 | [diff] [blame] | 38 | * A SCSI Command is assigned a nonzero serial_number before passed |
| 39 | * to the driver's queue command function. The serial_number is |
| 40 | * cleared when scsi_done is entered indicating that the command |
| 41 | * has been completed. It currently doesn't have much use other |
| 42 | * than printk's. Some lldd's use this number for other purposes. |
| 43 | * It's almost certain that such usages are either incorrect or |
| 44 | * meaningless. Please kill all usages other than printk's. Also, |
| 45 | * as this number is always identical to ->pid, please convert |
| 46 | * printk's to use ->pid, so that we can kill this field. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | */ |
| 48 | unsigned long serial_number; |
James Bottomley | b21a413 | 2005-08-05 21:45:40 -0500 | [diff] [blame] | 49 | /* |
| 50 | * This is set to jiffies as it was when the command was first |
| 51 | * allocated. It is used to time how long the command has |
| 52 | * been outstanding |
| 53 | */ |
| 54 | unsigned long jiffies_at_alloc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | |
| 56 | int retries; |
| 57 | int allowed; |
| 58 | int timeout_per_command; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | unsigned char cmd_len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | enum dma_data_direction sc_data_direction; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | /* These elements define the operation we are about to perform */ |
| 64 | #define MAX_COMMAND_SIZE 16 |
| 65 | unsigned char cmnd[MAX_COMMAND_SIZE]; |
| 66 | unsigned request_bufflen; /* Actual request size */ |
| 67 | |
| 68 | struct timer_list eh_timeout; /* Used to time out the command. */ |
| 69 | void *request_buffer; /* Actual requested buffer */ |
| 70 | |
| 71 | /* These elements define the operation we ultimately want to perform */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | unsigned short use_sg; /* Number of pieces of scatter-gather */ |
| 73 | unsigned short sglist_len; /* size of malloc'd scatter-gather list */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
| 75 | unsigned underflow; /* Return error if less than |
| 76 | this amount is transferred */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
| 78 | unsigned transfersize; /* How much we are guaranteed to |
| 79 | transfer with each SCSI transfer |
| 80 | (ie, between disconnect / |
| 81 | reconnects. Probably == sector |
| 82 | size */ |
| 83 | |
| 84 | int resid; /* Number of bytes requested to be |
| 85 | transferred less actual number |
| 86 | transferred (0 if not supported) */ |
| 87 | |
| 88 | struct request *request; /* The command we are |
| 89 | working on */ |
| 90 | |
| 91 | #define SCSI_SENSE_BUFFERSIZE 96 |
Matthew Wilcox | c67a848 | 2006-01-17 11:54:24 -0700 | [diff] [blame] | 92 | unsigned char sense_buffer[SCSI_SENSE_BUFFERSIZE]; |
| 93 | /* obtained by REQUEST SENSE when |
| 94 | * CHECK CONDITION is received on original |
| 95 | * command (auto-sense) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
| 97 | /* Low-level done function - can be used by low-level driver to point |
| 98 | * to completion function. Not used by mid/upper level code. */ |
| 99 | void (*scsi_done) (struct scsi_cmnd *); |
| 100 | |
| 101 | /* |
| 102 | * The following fields can be written to by the host specific code. |
| 103 | * Everything else should be left alone. |
| 104 | */ |
| 105 | struct scsi_pointer SCp; /* Scratchpad used by some host adapters */ |
| 106 | |
| 107 | unsigned char *host_scribble; /* The host adapter is allowed to |
Matthew Wilcox | c67a848 | 2006-01-17 11:54:24 -0700 | [diff] [blame] | 108 | * call scsi_malloc and get some memory |
| 109 | * and hang it here. The host adapter |
| 110 | * is also expected to call scsi_free |
| 111 | * to release this memory. (The memory |
| 112 | * obtained by scsi_malloc is guaranteed |
| 113 | * to be at an address < 16Mb). */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
| 115 | int result; /* Status code from lower level driver */ |
| 116 | |
| 117 | unsigned char tag; /* SCSI-II queued command tag */ |
| 118 | unsigned long pid; /* Process ID, starts at 0. Unique per host. */ |
| 119 | }; |
| 120 | |
| 121 | /* |
| 122 | * These are the values that scsi_cmd->state can take. |
| 123 | */ |
| 124 | #define SCSI_STATE_TIMEOUT 0x1000 |
| 125 | #define SCSI_STATE_FINISHED 0x1001 |
| 126 | #define SCSI_STATE_FAILED 0x1002 |
| 127 | #define SCSI_STATE_QUEUED 0x1003 |
| 128 | #define SCSI_STATE_UNUSED 0x1006 |
| 129 | #define SCSI_STATE_DISCONNECTING 0x1008 |
| 130 | #define SCSI_STATE_INITIALIZING 0x1009 |
| 131 | #define SCSI_STATE_BHQUEUE 0x100a |
| 132 | #define SCSI_STATE_MLQUEUE 0x100b |
| 133 | |
| 134 | |
Al Viro | c53033f | 2005-10-21 03:22:08 -0400 | [diff] [blame] | 135 | extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | extern void scsi_put_command(struct scsi_cmnd *); |
Luben Tuikov | 03aba2f | 2006-06-23 09:39:09 -0700 | [diff] [blame] | 137 | extern void scsi_io_completion(struct scsi_cmnd *, unsigned int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | extern void scsi_finish_command(struct scsi_cmnd *cmd); |
Luben Tuikov | 89f48c4 | 2006-05-15 20:57:18 +0900 | [diff] [blame] | 139 | extern void scsi_req_abort_cmd(struct scsi_cmnd *cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
Guennadi Liakhovetski | cdb8c2a | 2006-04-02 21:57:43 +0200 | [diff] [blame] | 141 | extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count, |
| 142 | size_t *offset, size_t *len); |
| 143 | extern void scsi_kunmap_atomic_sg(void *virt); |
| 144 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | #endif /* _SCSI_SCSI_CMND_H */ |