diff options
author | Boaz Harrosh <bharrosh@panasas.com> | 2007-12-13 06:47:40 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-01-30 14:03:40 -0500 |
commit | 30b0c37b27485a9cb897bfe3824f6f517b8c80d6 (patch) | |
tree | 22643da8e175ff7badf2413dc8c84b2e99613a6f /include/scsi | |
parent | bb52d82f45df3a2661d88befba7c79a7db8be496 (diff) |
[SCSI] implement scsi_data_buffer
In preparation for bidi we abstract all IO members of scsi_cmnd,
that will need to duplicate, into a substructure.
- Group all IO members of scsi_cmnd into a scsi_data_buffer
structure.
- Adjust accessors to new members.
- scsi_{alloc,free}_sgtable receive a scsi_data_buffer instead of
scsi_cmnd. And work on it.
- Adjust scsi_init_io() and scsi_release_buffers() for above
change.
- Fix other parts of scsi_lib/scsi.c to members migration. Use
accessors where appropriate.
- fix Documentation about scsi_cmnd in scsi_host.h
- scsi_error.c
* Changed needed members of struct scsi_eh_save.
* Careful considerations in scsi_eh_prep/restore_cmnd.
- sd.c and sr.c
* sd and sr would adjust IO size to align on device's block
size so code needs to change once we move to scsi_data_buff
implementation.
* Convert code to use scsi_for_each_sg
* Use data accessors where appropriate.
- tgt: convert libsrp to use scsi_data_buffer
- isd200: This driver still bangs on scsi_cmnd IO members,
so need changing
[jejb: rebased on top of sg_table patches fixed up conflicts
and used the synergy to eliminate use_sg and sg_count]
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'include/scsi')
-rw-r--r-- | include/scsi/scsi_cmnd.h | 36 | ||||
-rw-r--r-- | include/scsi/scsi_eh.h | 8 | ||||
-rw-r--r-- | include/scsi/scsi_host.h | 4 |
3 files changed, 27 insertions, 21 deletions
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 09d44f91dbdb..c6478bb6f963 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h | |||
@@ -11,6 +11,11 @@ struct request; | |||
11 | struct Scsi_Host; | 11 | struct Scsi_Host; |
12 | struct scsi_device; | 12 | struct scsi_device; |
13 | 13 | ||
14 | struct 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 */ |
16 | struct scsi_pointer { | 21 | struct 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 | ||
@@ -133,18 +130,29 @@ extern void scsi_release_buffers(struct scsi_cmnd *cmd); | |||
133 | extern int scsi_dma_map(struct scsi_cmnd *cmd); | 130 | extern int scsi_dma_map(struct scsi_cmnd *cmd); |
134 | extern void scsi_dma_unmap(struct scsi_cmnd *cmd); | 131 | extern void scsi_dma_unmap(struct scsi_cmnd *cmd); |
135 | 132 | ||
136 | #define scsi_sg_count(cmd) ((cmd)->use_sg) | 133 | static 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 | |||
138 | static inline struct scatterlist *scsi_sglist(struct scsi_cmnd *cmd) | ||
139 | { | ||
140 | return cmd->sdb.table.sgl; | ||
141 | } | ||
142 | |||
143 | static inline unsigned scsi_bufflen(struct scsi_cmnd *cmd) | ||
144 | { | ||
145 | return cmd->sdb.length; | ||
146 | } | ||
139 | 147 | ||
140 | static inline void scsi_set_resid(struct scsi_cmnd *cmd, int resid) | 148 | static 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 | ||
145 | static inline int scsi_get_resid(struct scsi_cmnd *cmd) | 153 | static 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) \ |
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h index d21b8913ceb3..1e08be1466ee 100644 --- a/include/scsi/scsi_eh.h +++ b/include/scsi/scsi_eh.h | |||
@@ -68,16 +68,14 @@ extern int scsi_get_sense_info_fld(const u8 * sense_buffer, int sb_len, | |||
68 | extern int scsi_reset_provider(struct scsi_device *, int); | 68 | extern int scsi_reset_provider(struct scsi_device *, int); |
69 | 69 | ||
70 | struct scsi_eh_save { | 70 | struct 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; | ||
75 | 77 | ||
76 | void *buffer; | 78 | /* new command support */ |
77 | unsigned bufflen; | ||
78 | unsigned short use_sg; | ||
79 | int resid; | ||
80 | |||
81 | struct scatterlist sense_sgl; | 79 | struct scatterlist sense_sgl; |
82 | }; | 80 | }; |
83 | 81 | ||
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 0fd4746ee39d..cb2bcab41dfb 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h | |||
@@ -136,9 +136,9 @@ struct scsi_host_template { | |||
136 | * the done callback is invoked. | 136 | * the done callback is invoked. |
137 | * | 137 | * |
138 | * This is called to inform the LLD to transfer | 138 | * This is called to inform the LLD to transfer |
139 | * cmd->request_bufflen bytes. The cmd->use_sg speciefies the | 139 | * scsi_bufflen(cmd) bytes. scsi_sg_count(cmd) speciefies the |
140 | * number of scatterlist entried in the command and | 140 | * number of scatterlist entried in the command and |
141 | * cmd->request_buffer contains the scatterlist. | 141 | * scsi_sglist(cmd) returns the scatterlist. |
142 | * | 142 | * |
143 | * return values: see queuecommand | 143 | * return values: see queuecommand |
144 | * | 144 | * |