queue.h 3.4 KB

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