queue.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * linux/drivers/acorn/scsi/queue.h: queue handling
  3. *
  4. * Copyright (C) 1997 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef QUEUE_H
  11. #define QUEUE_H
  12. typedef struct {
  13. struct list_head head;
  14. struct list_head free;
  15. spinlock_t queue_lock;
  16. void *alloc; /* start of allocated mem */
  17. } Queue_t;
  18. /*
  19. * Function: void queue_initialise (Queue_t *queue)
  20. * Purpose : initialise a queue
  21. * Params : queue - queue to initialise
  22. */
  23. extern int queue_initialise (Queue_t *queue);
  24. /*
  25. * Function: void queue_free (Queue_t *queue)
  26. * Purpose : free a queue
  27. * Params : queue - queue to free
  28. */
  29. extern void queue_free (Queue_t *queue);
  30. /*
  31. * Function: struct scsi_cmnd *queue_remove (queue)
  32. * Purpose : removes first SCSI command from a queue
  33. * Params : queue - queue to remove command from
  34. * Returns : struct scsi_cmnd if successful (and a reference), or NULL if no command available
  35. */
  36. extern struct scsi_cmnd *queue_remove (Queue_t *queue);
  37. /*
  38. * Function: struct scsi_cmnd *queue_remove_exclude_ref (queue, exclude)
  39. * Purpose : remove a SCSI command from a queue
  40. * Params : queue - queue to remove command from
  41. * exclude - array of busy LUNs
  42. * Returns : struct scsi_cmnd if successful (and a reference), or NULL if no command available
  43. */
  44. extern struct scsi_cmnd *queue_remove_exclude(Queue_t *queue,
  45. unsigned long *exclude);
  46. #define queue_add_cmd_ordered(queue,SCpnt) \
  47. __queue_add(queue,SCpnt,(SCpnt)->cmnd[0] == REQUEST_SENSE)
  48. #define queue_add_cmd_tail(queue,SCpnt) \
  49. __queue_add(queue,SCpnt,0)
  50. /*
  51. * Function: int __queue_add(Queue_t *queue, struct scsi_cmnd *SCpnt, int head)
  52. * Purpose : Add a new command onto a queue
  53. * Params : queue - destination queue
  54. * SCpnt - command to add
  55. * head - add command to head of queue
  56. * Returns : 0 on error, !0 on success
  57. */
  58. extern int __queue_add(Queue_t *queue, struct scsi_cmnd *SCpnt, int head);
  59. /*
  60. * Function: struct scsi_cmnd *queue_remove_tgtluntag (queue, target, lun, tag)
  61. * Purpose : remove a SCSI command from the queue for a specified target/lun/tag
  62. * Params : queue - queue to remove command from
  63. * target - target that we want
  64. * lun - lun on device
  65. * tag - tag on device
  66. * Returns : struct scsi_cmnd if successful, or NULL if no command satisfies requirements
  67. */
  68. extern struct scsi_cmnd *queue_remove_tgtluntag(Queue_t *queue, int target,
  69. int lun, int tag);
  70. /*
  71. * Function: queue_remove_all_target(queue, target)
  72. * Purpose : remove all SCSI commands from the queue for a specified target
  73. * Params : queue - queue to remove command from
  74. * target - target device id
  75. * Returns : nothing
  76. */
  77. extern void queue_remove_all_target(Queue_t *queue, int target);
  78. /*
  79. * Function: int queue_probetgtlun (queue, target, lun)
  80. * Purpose : check to see if we have a command in the queue for the specified
  81. * target/lun.
  82. * Params : queue - queue to look in
  83. * target - target we want to probe
  84. * lun - lun on target
  85. * Returns : 0 if not found, != 0 if found
  86. */
  87. extern int queue_probetgtlun (Queue_t *queue, int target, int lun);
  88. /*
  89. * Function: int queue_remove_cmd (Queue_t *queue, struct scsi_cmnd *SCpnt)
  90. * Purpose : remove a specific command from the queues
  91. * Params : queue - queue to look in
  92. * SCpnt - command to find
  93. * Returns : 0 if not found
  94. */
  95. int queue_remove_cmd(Queue_t *queue, struct scsi_cmnd *SCpnt);
  96. #endif /* QUEUE_H */