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