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