scsi_cmnd.h 5.1 KB

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