scsi_cmnd.h 5.0 KB

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