queue.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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: Scsi_Cmnd *queue_remove (queue)
  32. * Purpose : removes first SCSI command from a queue
  33. * Params : queue - queue to remove command from
  34. * Returns : Scsi_Cmnd if successful (and a reference), or NULL if no command available
  35. */
  36. extern Scsi_Cmnd *queue_remove (Queue_t *queue);
  37. /*
  38. * Function: 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 : Scsi_Cmnd if successful (and a reference), or NULL if no command available
  43. */
  44. extern Scsi_Cmnd *queue_remove_exclude (Queue_t *queue, unsigned long *exclude);
  45. #define queue_add_cmd_ordered(queue,SCpnt) \
  46. __queue_add(queue,SCpnt,(SCpnt)->cmnd[0] == REQUEST_SENSE)
  47. #define queue_add_cmd_tail(queue,SCpnt) \
  48. __queue_add(queue,SCpnt,0)
  49. /*
  50. * Function: int __queue_add(Queue_t *queue, Scsi_Cmnd *SCpnt, int head)
  51. * Purpose : Add a new command onto a queue
  52. * Params : queue - destination queue
  53. * SCpnt - command to add
  54. * head - add command to head of queue
  55. * Returns : 0 on error, !0 on success
  56. */
  57. extern int __queue_add(Queue_t *queue, Scsi_Cmnd *SCpnt, int head);
  58. /*
  59. * Function: Scsi_Cmnd *queue_remove_tgtluntag (queue, target, lun, tag)
  60. * Purpose : remove a SCSI command from the queue for a specified target/lun/tag
  61. * Params : queue - queue to remove command from
  62. * target - target that we want
  63. * lun - lun on device
  64. * tag - tag on device
  65. * Returns : Scsi_Cmnd if successful, or NULL if no command satisfies requirements
  66. */
  67. extern Scsi_Cmnd *queue_remove_tgtluntag (Queue_t *queue, int target, int lun, int tag);
  68. /*
  69. * Function: queue_remove_all_target(queue, target)
  70. * Purpose : remove all SCSI commands from the queue for a specified target
  71. * Params : queue - queue to remove command from
  72. * target - target device id
  73. * Returns : nothing
  74. */
  75. extern void queue_remove_all_target(Queue_t *queue, int target);
  76. /*
  77. * Function: int queue_probetgtlun (queue, target, lun)
  78. * Purpose : check to see if we have a command in the queue for the specified
  79. * target/lun.
  80. * Params : queue - queue to look in
  81. * target - target we want to probe
  82. * lun - lun on target
  83. * Returns : 0 if not found, != 0 if found
  84. */
  85. extern int queue_probetgtlun (Queue_t *queue, int target, int lun);
  86. /*
  87. * Function: int queue_remove_cmd (Queue_t *queue, Scsi_Cmnd *SCpnt)
  88. * Purpose : remove a specific command from the queues
  89. * Params : queue - queue to look in
  90. * SCpnt - command to find
  91. * Returns : 0 if not found
  92. */
  93. int queue_remove_cmd(Queue_t *queue, Scsi_Cmnd *SCpnt);
  94. #endif /* QUEUE_H */