1 |
199 |
simons |
/*
|
2 |
|
|
* queue.h: queue handling
|
3 |
|
|
*
|
4 |
|
|
* (c) 1997 Russell King
|
5 |
|
|
*/
|
6 |
|
|
#ifndef QUEUE_H
|
7 |
|
|
#define QUEUE_H
|
8 |
|
|
|
9 |
|
|
typedef struct {
|
10 |
|
|
struct queue_entry *head; /* head of queue */
|
11 |
|
|
struct queue_entry *tail; /* tail of queue */
|
12 |
|
|
struct queue_entry *free; /* free list */
|
13 |
|
|
void *alloc; /* start of allocated mem */
|
14 |
|
|
} Queue_t;
|
15 |
|
|
|
16 |
|
|
/*
|
17 |
|
|
* Function: void queue_initialise (Queue_t *queue)
|
18 |
|
|
* Purpose : initialise a queue
|
19 |
|
|
* Params : queue - queue to initialise
|
20 |
|
|
*/
|
21 |
|
|
extern int queue_initialise (Queue_t *queue);
|
22 |
|
|
|
23 |
|
|
/*
|
24 |
|
|
* Function: void queue_free (Queue_t *queue)
|
25 |
|
|
* Purpose : free a queue
|
26 |
|
|
* Params : queue - queue to free
|
27 |
|
|
*/
|
28 |
|
|
extern void queue_free (Queue_t *queue);
|
29 |
|
|
|
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 |
|
|
/*
|
39 |
|
|
* Function: Scsi_Cmnd *queue_remove_exclude_ref (queue, exclude, ref)
|
40 |
|
|
* Purpose : remove a SCSI command from a queue
|
41 |
|
|
* Params : queue - queue to remove command from
|
42 |
|
|
* exclude - array of busy LUNs
|
43 |
|
|
* ref - a reference that can be used to put the command back
|
44 |
|
|
* Returns : Scsi_Cmnd if successful (and a reference), or NULL if no command available
|
45 |
|
|
*/
|
46 |
|
|
extern Scsi_Cmnd *queue_remove_exclude (Queue_t *queue, unsigned char *exclude);
|
47 |
|
|
|
48 |
|
|
/*
|
49 |
|
|
* Function: int queue_add_cmd_ordered (Queue_t *queue, Scsi_Cmnd *SCpnt)
|
50 |
|
|
* Purpose : Add a new command onto a queue, queueing REQUEST_SENSE first
|
51 |
|
|
* Params : queue - destination queue
|
52 |
|
|
* SCpnt - command to add
|
53 |
|
|
* Returns : 0 on error, !0 on success
|
54 |
|
|
*/
|
55 |
|
|
extern int queue_add_cmd_ordered (Queue_t *queue, Scsi_Cmnd *SCpnt);
|
56 |
|
|
|
57 |
|
|
/*
|
58 |
|
|
* Function: int queue_add_cmd_tail (Queue_t *queue, Scsi_Cmnd *SCpnt)
|
59 |
|
|
* Purpose : Add a new command onto a queue, queueing at end of list
|
60 |
|
|
* Params : queue - destination queue
|
61 |
|
|
* SCpnt - command to add
|
62 |
|
|
* Returns : 0 on error, !0 on success
|
63 |
|
|
*/
|
64 |
|
|
extern int queue_add_cmd_tail (Queue_t *queue, Scsi_Cmnd *SCpnt);
|
65 |
|
|
|
66 |
|
|
/*
|
67 |
|
|
* Function: Scsi_Cmnd *queue_remove_tgtluntag (queue, target, lun, tag)
|
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
|
73 |
|
|
* Returns : Scsi_Cmnd if successful, or NULL if no command satisfies requirements
|
74 |
|
|
*/
|
75 |
|
|
extern Scsi_Cmnd *queue_remove_tgtluntag (Queue_t *queue, int target, int lun, int tag);
|
76 |
|
|
|
77 |
|
|
/*
|
78 |
|
|
* Function: int queue_probetgtlun (queue, target, lun)
|
79 |
|
|
* Purpose : check to see if we have a command in the queue for the specified
|
80 |
|
|
* target/lun.
|
81 |
|
|
* Params : queue - queue to look in
|
82 |
|
|
* target - target we want to probe
|
83 |
|
|
* lun - lun on target
|
84 |
|
|
* Returns : 0 if not found, != 0 if found
|
85 |
|
|
*/
|
86 |
|
|
extern int queue_probetgtlun (Queue_t *queue, int target, int lun);
|
87 |
|
|
|
88 |
|
|
/*
|
89 |
|
|
* Function: int queue_cmdonqueue (queue, SCpnt)
|
90 |
|
|
* Purpose : check to see if we have a command on the queue
|
91 |
|
|
* Params : queue - queue to look in
|
92 |
|
|
* SCpnt - command to find
|
93 |
|
|
* Returns : 0 if not found, != 0 if found
|
94 |
|
|
*/
|
95 |
|
|
int queue_cmdonqueue (Queue_t *queue, Scsi_Cmnd *SCpnt);
|
96 |
|
|
|
97 |
|
|
/*
|
98 |
|
|
* Function: int queue_removecmd (Queue_t *queue, Scsi_Cmnd *SCpnt)
|
99 |
|
|
* Purpose : remove a specific command from the queues
|
100 |
|
|
* Params : queue - queue to look in
|
101 |
|
|
* SCpnt - command to find
|
102 |
|
|
* Returns : 0 if not found
|
103 |
|
|
*/
|
104 |
|
|
int queue_removecmd (Queue_t *queue, Scsi_Cmnd *SCpnt);
|
105 |
|
|
|
106 |
|
|
#endif /* QUEUE_H */
|