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