aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/scsi/scsi.h20
-rw-r--r--include/scsi/scsi_cmnd.h59
-rw-r--r--include/scsi/scsi_eh.h9
-rw-r--r--include/scsi/scsi_host.h17
4 files changed, 68 insertions, 37 deletions
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 702fcfeb37f1..82251575a9b4 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -11,6 +11,25 @@
11#include <linux/types.h> 11#include <linux/types.h>
12 12
13/* 13/*
14 * The maximum number of SG segments that we will put inside a
15 * scatterlist (unless chaining is used). Should ideally fit inside a
16 * single page, to avoid a higher order allocation. We could define this
17 * to SG_MAX_SINGLE_ALLOC to pack correctly at the highest order. The
18 * minimum value is 32
19 */
20#define SCSI_MAX_SG_SEGMENTS 128
21
22/*
23 * Like SCSI_MAX_SG_SEGMENTS, but for archs that have sg chaining. This limit
24 * is totally arbitrary, a setting of 2048 will get you at least 8mb ios.
25 */
26#ifdef ARCH_HAS_SG_CHAIN
27#define SCSI_MAX_SG_CHAIN_SEGMENTS 2048
28#else
29#define SCSI_MAX_SG_CHAIN_SEGMENTS SCSI_MAX_SG_SEGMENTS
30#endif
31
32/*
14 * SCSI command lengths 33 * SCSI command lengths
15 */ 34 */
16 35
@@ -83,6 +102,7 @@ extern const unsigned char scsi_command_size[8];
83#define READ_TOC 0x43 102#define READ_TOC 0x43
84#define LOG_SELECT 0x4c 103#define LOG_SELECT 0x4c
85#define LOG_SENSE 0x4d 104#define LOG_SENSE 0x4d
105#define XDWRITEREAD_10 0x53
86#define MODE_SELECT_10 0x55 106#define MODE_SELECT_10 0x55
87#define RESERVE_10 0x56 107#define RESERVE_10 0x56
88#define RELEASE_10 0x57 108#define RELEASE_10 0x57
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index a457fca66f61..de28aab820b0 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -2,15 +2,20 @@
2#define _SCSI_SCSI_CMND_H 2#define _SCSI_SCSI_CMND_H
3 3
4#include <linux/dma-mapping.h> 4#include <linux/dma-mapping.h>
5#include <linux/blkdev.h>
5#include <linux/list.h> 6#include <linux/list.h>
6#include <linux/types.h> 7#include <linux/types.h>
7#include <linux/timer.h> 8#include <linux/timer.h>
8#include <linux/scatterlist.h> 9#include <linux/scatterlist.h>
9 10
10struct request;
11struct Scsi_Host; 11struct Scsi_Host;
12struct scsi_device; 12struct scsi_device;
13 13
14struct scsi_data_buffer {
15 struct sg_table table;
16 unsigned length;
17 int resid;
18};
14 19
15/* embedded in scsi_cmnd */ 20/* embedded in scsi_cmnd */
16struct scsi_pointer { 21struct scsi_pointer {
@@ -61,15 +66,11 @@ struct scsi_cmnd {
61 /* These elements define the operation we are about to perform */ 66 /* These elements define the operation we are about to perform */
62#define MAX_COMMAND_SIZE 16 67#define MAX_COMMAND_SIZE 16
63 unsigned char cmnd[MAX_COMMAND_SIZE]; 68 unsigned char cmnd[MAX_COMMAND_SIZE];
64 unsigned request_bufflen; /* Actual request size */
65 69
66 struct timer_list eh_timeout; /* Used to time out the command. */ 70 struct timer_list eh_timeout; /* Used to time out the command. */
67 void *request_buffer; /* Actual requested buffer */
68 71
69 /* These elements define the operation we ultimately want to perform */ 72 /* These elements define the operation we ultimately want to perform */
70 struct sg_table sg_table; 73 struct scsi_data_buffer sdb;
71 unsigned short use_sg; /* Number of pieces of scatter-gather */
72
73 unsigned underflow; /* Return error if less than 74 unsigned underflow; /* Return error if less than
74 this amount is transferred */ 75 this amount is transferred */
75 76
@@ -79,10 +80,6 @@ struct scsi_cmnd {
79 reconnects. Probably == sector 80 reconnects. Probably == sector
80 size */ 81 size */
81 82
82 int resid; /* Number of bytes requested to be
83 transferred less actual number
84 transferred (0 if not supported) */
85
86 struct request *request; /* The command we are 83 struct request *request; /* The command we are
87 working on */ 84 working on */
88 85
@@ -127,27 +124,55 @@ extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
127 size_t *offset, size_t *len); 124 size_t *offset, size_t *len);
128extern void scsi_kunmap_atomic_sg(void *virt); 125extern void scsi_kunmap_atomic_sg(void *virt);
129 126
130extern int scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t); 127extern int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask);
131extern void scsi_free_sgtable(struct scsi_cmnd *); 128extern void scsi_release_buffers(struct scsi_cmnd *cmd);
132 129
133extern int scsi_dma_map(struct scsi_cmnd *cmd); 130extern int scsi_dma_map(struct scsi_cmnd *cmd);
134extern void scsi_dma_unmap(struct scsi_cmnd *cmd); 131extern void scsi_dma_unmap(struct scsi_cmnd *cmd);
135 132
136#define scsi_sg_count(cmd) ((cmd)->use_sg) 133static inline unsigned scsi_sg_count(struct scsi_cmnd *cmd)
137#define scsi_sglist(cmd) ((cmd)->sg_table.sgl) 134{
138#define scsi_bufflen(cmd) ((cmd)->request_bufflen) 135 return cmd->sdb.table.nents;
136}
137
138static inline struct scatterlist *scsi_sglist(struct scsi_cmnd *cmd)
139{
140 return cmd->sdb.table.sgl;
141}
142
143static inline unsigned scsi_bufflen(struct scsi_cmnd *cmd)
144{
145 return cmd->sdb.length;
146}
139 147
140static inline void scsi_set_resid(struct scsi_cmnd *cmd, int resid) 148static inline void scsi_set_resid(struct scsi_cmnd *cmd, int resid)
141{ 149{
142 cmd->resid = resid; 150 cmd->sdb.resid = resid;
143} 151}
144 152
145static inline int scsi_get_resid(struct scsi_cmnd *cmd) 153static inline int scsi_get_resid(struct scsi_cmnd *cmd)
146{ 154{
147 return cmd->resid; 155 return cmd->sdb.resid;
148} 156}
149 157
150#define scsi_for_each_sg(cmd, sg, nseg, __i) \ 158#define scsi_for_each_sg(cmd, sg, nseg, __i) \
151 for_each_sg(scsi_sglist(cmd), sg, nseg, __i) 159 for_each_sg(scsi_sglist(cmd), sg, nseg, __i)
152 160
161static inline int scsi_bidi_cmnd(struct scsi_cmnd *cmd)
162{
163 return blk_bidi_rq(cmd->request) &&
164 (cmd->request->next_rq->special != NULL);
165}
166
167static inline struct scsi_data_buffer *scsi_in(struct scsi_cmnd *cmd)
168{
169 return scsi_bidi_cmnd(cmd) ?
170 cmd->request->next_rq->special : &cmd->sdb;
171}
172
173static inline struct scsi_data_buffer *scsi_out(struct scsi_cmnd *cmd)
174{
175 return &cmd->sdb;
176}
177
153#endif /* _SCSI_SCSI_CMND_H */ 178#endif /* _SCSI_SCSI_CMND_H */
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index d21b8913ceb3..25071d5d9bf8 100644
--- a/include/scsi/scsi_eh.h
+++ b/include/scsi/scsi_eh.h
@@ -68,16 +68,15 @@ extern int scsi_get_sense_info_fld(const u8 * sense_buffer, int sb_len,
68extern int scsi_reset_provider(struct scsi_device *, int); 68extern int scsi_reset_provider(struct scsi_device *, int);
69 69
70struct scsi_eh_save { 70struct scsi_eh_save {
71 /* saved state */
71 int result; 72 int result;
72 enum dma_data_direction data_direction; 73 enum dma_data_direction data_direction;
73 unsigned char cmd_len; 74 unsigned char cmd_len;
74 unsigned char cmnd[MAX_COMMAND_SIZE]; 75 unsigned char cmnd[MAX_COMMAND_SIZE];
76 struct scsi_data_buffer sdb;
77 struct request *next_rq;
75 78
76 void *buffer; 79 /* new command support */
77 unsigned bufflen;
78 unsigned short use_sg;
79 int resid;
80
81 struct scatterlist sense_sgl; 80 struct scatterlist sense_sgl;
82}; 81};
83 82
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 0fd4746ee39d..5c58d594126a 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -39,9 +39,6 @@ struct blk_queue_tags;
39#define DISABLE_CLUSTERING 0 39#define DISABLE_CLUSTERING 0
40#define ENABLE_CLUSTERING 1 40#define ENABLE_CLUSTERING 1
41 41
42#define DISABLE_SG_CHAINING 0
43#define ENABLE_SG_CHAINING 1
44
45enum scsi_eh_timer_return { 42enum scsi_eh_timer_return {
46 EH_NOT_HANDLED, 43 EH_NOT_HANDLED,
47 EH_HANDLED, 44 EH_HANDLED,
@@ -136,9 +133,9 @@ struct scsi_host_template {
136 * the done callback is invoked. 133 * the done callback is invoked.
137 * 134 *
138 * This is called to inform the LLD to transfer 135 * This is called to inform the LLD to transfer
139 * cmd->request_bufflen bytes. The cmd->use_sg speciefies the 136 * scsi_bufflen(cmd) bytes. scsi_sg_count(cmd) speciefies the
140 * number of scatterlist entried in the command and 137 * number of scatterlist entried in the command and
141 * cmd->request_buffer contains the scatterlist. 138 * scsi_sglist(cmd) returns the scatterlist.
142 * 139 *
143 * return values: see queuecommand 140 * return values: see queuecommand
144 * 141 *
@@ -446,15 +443,6 @@ struct scsi_host_template {
446 unsigned ordered_tag:1; 443 unsigned ordered_tag:1;
447 444
448 /* 445 /*
449 * true if the low-level driver can support sg chaining. this
450 * will be removed eventually when all the drivers are
451 * converted to support sg chaining.
452 *
453 * Status: OBSOLETE
454 */
455 unsigned use_sg_chaining:1;
456
457 /*
458 * Countdown for host blocking with no commands outstanding 446 * Countdown for host blocking with no commands outstanding
459 */ 447 */
460 unsigned int max_host_blocked; 448 unsigned int max_host_blocked;
@@ -598,7 +586,6 @@ struct Scsi_Host {
598 unsigned unchecked_isa_dma:1; 586 unsigned unchecked_isa_dma:1;
599 unsigned use_clustering:1; 587 unsigned use_clustering:1;
600 unsigned use_blk_tcq:1; 588 unsigned use_blk_tcq:1;
601 unsigned use_sg_chaining:1;
602 589
603 /* 590 /*
604 * Host has requested that no further requests come through for the 591 * Host has requested that no further requests come through for the