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