1 #ifndef _SCSI_SCSI_CMND_H
2 #define _SCSI_SCSI_CMND_H
6 #include <linux/list.h>
7 #include <linux/types.h>
27 #define MAX_COMMAND_SIZE 16
28 #if (MAX_COMMAND_SIZE > BLK_MAX_CDB)
29 # error MAX_COMMAND_SIZE can not be bigger than BLK_MAX_CDB
106 #define SCSI_SENSE_BUFFERSIZE 96
149 size_t *
offset,
size_t *len);
161 static inline unsigned scsi_sg_count(
struct scsi_cmnd *
cmd)
163 return cmd->
sdb.table.nents;
168 return cmd->
sdb.table.sgl;
171 static inline unsigned scsi_bufflen(
struct scsi_cmnd *
cmd)
173 return cmd->
sdb.length;
176 static inline void scsi_set_resid(
struct scsi_cmnd *
cmd,
int resid)
178 cmd->
sdb.resid = resid;
183 return cmd->
sdb.resid;
186 #define scsi_for_each_sg(cmd, sg, nseg, __i) \
187 for_each_sg(scsi_sglist(cmd), sg, nseg, __i)
191 return blk_bidi_rq(cmd->
request) &&
197 return scsi_bidi_cmnd(cmd) ?
206 static inline int scsi_sg_copy_from_buffer(
struct scsi_cmnd *
cmd,
213 static inline int scsi_sg_copy_to_buffer(
struct scsi_cmnd *cmd,
214 void *buf,
int buflen)
241 static inline void scsi_set_prot_op(
struct scsi_cmnd *scmd,
unsigned char op)
246 static inline unsigned char scsi_get_prot_op(
struct scsi_cmnd *scmd)
264 static inline void scsi_set_prot_type(
struct scsi_cmnd *scmd,
unsigned char type)
269 static inline unsigned char scsi_get_prot_type(
struct scsi_cmnd *scmd)
276 return blk_rq_pos(scmd->
request);
279 static inline unsigned scsi_prot_sg_count(
struct scsi_cmnd *cmd)
294 #define scsi_for_each_prot_sg(cmd, sg, nseg, __i) \
295 for_each_sg(scsi_prot_sglist(cmd), sg, nseg, __i)
299 cmd->
result = (cmd->
result & 0xffff00ff) | (status << 8);
304 cmd->
result = (cmd->
result & 0xff00ffff) | (status << 16);
307 static inline void set_driver_byte(
struct scsi_cmnd *cmd,
char status)
309 cmd->
result = (cmd->
result & 0x00ffffff) | (status << 24);