scsi_cmnd.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. enum dma_data_direction sc_data_direction;
  52. /* These elements define the operation we are about to perform */
  53. #define MAX_COMMAND_SIZE 16
  54. unsigned char cmnd[MAX_COMMAND_SIZE];
  55. unsigned request_bufflen; /* Actual request size */
  56. struct timer_list eh_timeout; /* Used to time out the command. */
  57. void *request_buffer; /* Actual requested buffer */
  58. /* These elements define the operation we ultimately want to perform */
  59. unsigned short use_sg; /* Number of pieces of scatter-gather */
  60. unsigned short sglist_len; /* size of malloc'd scatter-gather list */
  61. unsigned underflow; /* Return error if less than
  62. this amount is transferred */
  63. unsigned transfersize; /* How much we are guaranteed to
  64. transfer with each SCSI transfer
  65. (ie, between disconnect /
  66. reconnects. Probably == sector
  67. size */
  68. int resid; /* Number of bytes requested to be
  69. transferred less actual number
  70. transferred (0 if not supported) */
  71. struct request *request; /* The command we are
  72. working on */
  73. #define SCSI_SENSE_BUFFERSIZE 96
  74. unsigned char sense_buffer[SCSI_SENSE_BUFFERSIZE];
  75. /* obtained by REQUEST SENSE when
  76. * CHECK CONDITION is received on original
  77. * command (auto-sense) */
  78. /* Low-level done function - can be used by low-level driver to point
  79. * to completion function. Not used by mid/upper level code. */
  80. void (*scsi_done) (struct scsi_cmnd *);
  81. /*
  82. * The following fields can be written to by the host specific code.
  83. * Everything else should be left alone.
  84. */
  85. struct scsi_pointer SCp; /* Scratchpad used by some host adapters */
  86. unsigned char *host_scribble; /* The host adapter is allowed to
  87. * call scsi_malloc and get some memory
  88. * and hang it here. The host adapter
  89. * is also expected to call scsi_free
  90. * to release this memory. (The memory
  91. * obtained by scsi_malloc is guaranteed
  92. * to be at an address < 16Mb). */
  93. int result; /* Status code from lower level driver */
  94. unsigned char tag; /* SCSI-II queued command tag */
  95. unsigned long pid; /* Process ID, starts at 0. Unique per host. */
  96. };
  97. extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t);
  98. extern void scsi_put_command(struct scsi_cmnd *);
  99. extern void scsi_io_completion(struct scsi_cmnd *, unsigned int);
  100. extern void scsi_finish_command(struct scsi_cmnd *cmd);
  101. extern void scsi_req_abort_cmd(struct scsi_cmnd *cmd);
  102. extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
  103. size_t *offset, size_t *len);
  104. extern void scsi_kunmap_atomic_sg(void *virt);
  105. #endif /* _SCSI_SCSI_CMND_H */