scsi_cmnd.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #ifndef _SCSI_SCSI_CMND_H
  2. #define _SCSI_SCSI_CMND_H
  3. #include <linux/dma-mapping.h>
  4. #include <linux/list.h>
  5. #include <linux/types.h>
  6. #include <linux/timer.h>
  7. struct request;
  8. struct scatterlist;
  9. struct Scsi_Host;
  10. struct scsi_device;
  11. /* embedded in scsi_cmnd */
  12. struct scsi_pointer {
  13. char *ptr; /* data pointer */
  14. int this_residual; /* left in this buffer */
  15. struct scatterlist *buffer; /* which buffer */
  16. int buffers_residual; /* how many buffers left */
  17. dma_addr_t dma_handle;
  18. volatile int Status;
  19. volatile int Message;
  20. volatile int have_data_in;
  21. volatile int sent_command;
  22. volatile int phase;
  23. };
  24. struct scsi_cmnd {
  25. struct scsi_device *device;
  26. struct list_head list; /* scsi_cmnd participates in queue lists */
  27. struct list_head eh_entry; /* entry for the host eh_cmd_q */
  28. int eh_eflags; /* Used by error handlr */
  29. void (*done) (struct scsi_cmnd *); /* Mid-level done function */
  30. /*
  31. * A SCSI Command is assigned a nonzero serial_number before passed
  32. * to the driver's queue command function. The serial_number is
  33. * cleared when scsi_done is entered indicating that the command
  34. * has been completed. It currently doesn't have much use other
  35. * than printk's. Some lldd's use this number for other purposes.
  36. * It's almost certain that such usages are either incorrect or
  37. * meaningless. Please kill all usages other than printk's. Also,
  38. * as this number is always identical to ->pid, please convert
  39. * printk's to use ->pid, so that we can kill this field.
  40. */
  41. unsigned long serial_number;
  42. /*
  43. * This is set to jiffies as it was when the command was first
  44. * allocated. It is used to time how long the command has
  45. * been outstanding
  46. */
  47. unsigned long jiffies_at_alloc;
  48. int retries;
  49. int allowed;
  50. int timeout_per_command;
  51. unsigned char cmd_len;
  52. enum dma_data_direction sc_data_direction;
  53. /* These elements define the operation we are about to perform */
  54. #define MAX_COMMAND_SIZE 16
  55. unsigned char cmnd[MAX_COMMAND_SIZE];
  56. unsigned request_bufflen; /* Actual request size */
  57. struct timer_list eh_timeout; /* Used to time out the command. */
  58. void *request_buffer; /* Actual requested buffer */
  59. /* These elements define the operation we ultimately want to perform */
  60. unsigned short use_sg; /* Number of pieces of scatter-gather */
  61. unsigned short sglist_len; /* size of malloc'd scatter-gather list */
  62. /* offset in cmd we are at (for multi-transfer tgt cmds) */
  63. unsigned offset;
  64. unsigned underflow; /* Return error if less than
  65. this amount is transferred */
  66. unsigned transfersize; /* How much we are guaranteed to
  67. transfer with each SCSI transfer
  68. (ie, between disconnect /
  69. reconnects. Probably == sector
  70. size */
  71. int resid; /* Number of bytes requested to be
  72. transferred less actual number
  73. transferred (0 if not supported) */
  74. struct request *request; /* The command we are
  75. working on */
  76. #define SCSI_SENSE_BUFFERSIZE 96
  77. unsigned char sense_buffer[SCSI_SENSE_BUFFERSIZE];
  78. /* obtained by REQUEST SENSE when
  79. * CHECK CONDITION is received on original
  80. * command (auto-sense) */
  81. /* Low-level done function - can be used by low-level driver to point
  82. * to completion function. Not used by mid/upper level code. */
  83. void (*scsi_done) (struct scsi_cmnd *);
  84. /*
  85. * The following fields can be written to by the host specific code.
  86. * Everything else should be left alone.
  87. */
  88. struct scsi_pointer SCp; /* Scratchpad used by some host adapters */
  89. unsigned char *host_scribble; /* The host adapter is allowed to
  90. * call scsi_malloc and get some memory
  91. * and hang it here. The host adapter
  92. * is also expected to call scsi_free
  93. * to release this memory. (The memory
  94. * obtained by scsi_malloc is guaranteed
  95. * to be at an address < 16Mb). */
  96. int result; /* Status code from lower level driver */
  97. unsigned char tag; /* SCSI-II queued command tag */
  98. unsigned long pid; /* Process ID, starts at 0. Unique per host. */
  99. };
  100. extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t);
  101. extern struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *, gfp_t);
  102. extern void scsi_put_command(struct scsi_cmnd *);
  103. extern void __scsi_put_command(struct Scsi_Host *, struct scsi_cmnd *,
  104. struct device *);
  105. extern void scsi_io_completion(struct scsi_cmnd *, unsigned int);
  106. extern void scsi_finish_command(struct scsi_cmnd *cmd);
  107. extern void scsi_req_abort_cmd(struct scsi_cmnd *cmd);
  108. extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
  109. size_t *offset, size_t *len);
  110. extern void scsi_kunmap_atomic_sg(void *virt);
  111. extern struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t);
  112. extern void scsi_free_sgtable(struct scatterlist *, int);
  113. #endif /* _SCSI_SCSI_CMND_H */