Lines Matching +full:- +full:- +full:target +full:- +full:list

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 1997-2000 Russell King
8 * 15-Sep-1997 RMK Created.
9 * 11-Oct-1997 RMK Corrected problem with queue_remove_exclude
10 * not updating internal linked list properly
12 * 30-Aug-2000 RMK Use Linux list handling and spinlocks
20 #include <linux/list.h>
32 struct list_head list; member
43 #define SET_MAGIC(q,m) ((q)->magic = (m))
44 #define BAD_MAGIC(q,m) ((q)->magic != (m))
57 * Params : queue - queue to initialise
64 spin_lock_init(&queue->queue_lock); in queue_initialise()
65 INIT_LIST_HEAD(&queue->head); in queue_initialise()
66 INIT_LIST_HEAD(&queue->free); in queue_initialise()
70 * host-available list head, and we wouldn't in queue_initialise()
74 queue->alloc = q = kmalloc_array(nqueues, sizeof(QE_t), GFP_KERNEL); in queue_initialise()
76 for (; nqueues; q++, nqueues--) { in queue_initialise()
78 q->SCpnt = NULL; in queue_initialise()
79 list_add(&q->list, &queue->free); in queue_initialise()
83 return queue->alloc != NULL; in queue_initialise()
89 * Params : queue - queue to free
93 if (!list_empty(&queue->head)) in queue_free()
94 printk(KERN_WARNING "freeing non-empty queue %p\n", queue); in queue_free()
95 kfree(queue->alloc); in queue_free()
102 * Params : queue - destination queue
103 * SCpnt - command to add
104 * head - add command to head of queue
114 spin_lock_irqsave(&queue->queue_lock, flags); in __queue_add()
115 if (list_empty(&queue->free)) in __queue_add()
118 l = queue->free.next; in __queue_add()
121 q = list_entry(l, QE_t, list); in __queue_add()
125 q->SCpnt = SCpnt; in __queue_add()
128 list_add(l, &queue->head); in __queue_add()
130 list_add_tail(l, &queue->head); in __queue_add()
134 spin_unlock_irqrestore(&queue->queue_lock, flags); in __queue_add()
143 * Move the entry from the "used" list onto the "free" list in __queue_remove()
146 q = list_entry(ent, QE_t, list); in __queue_remove()
150 list_add(ent, &queue->free); in __queue_remove()
152 return q->SCpnt; in __queue_remove()
158 * Params : queue - queue to remove command from
159 * exclude - bit array of target&lun which is busy
168 spin_lock_irqsave(&queue->queue_lock, flags); in queue_remove_exclude()
169 list_for_each(l, &queue->head) { in queue_remove_exclude()
170 QE_t *q = list_entry(l, QE_t, list); in queue_remove_exclude()
171 if (!test_bit(q->SCpnt->device->id * 8 + in queue_remove_exclude()
172 (u8)(q->SCpnt->device->lun & 0x7), exclude)) { in queue_remove_exclude()
177 spin_unlock_irqrestore(&queue->queue_lock, flags); in queue_remove_exclude()
185 * Params : queue - queue to remove command from
193 spin_lock_irqsave(&queue->queue_lock, flags); in queue_remove()
194 if (!list_empty(&queue->head)) in queue_remove()
195 SCpnt = __queue_remove(queue, queue->head.next); in queue_remove()
196 spin_unlock_irqrestore(&queue->queue_lock, flags); in queue_remove()
202 * Function: struct scsi_cmnd *queue_remove_tgtluntag (queue, target, lun, tag)
203 * Purpose : remove a SCSI command from the queue for a specified target/lun/tag
204 * Params : queue - queue to remove command from
205 * target - target that we want
206 * lun - lun on device
207 * tag - tag on device
210 struct scsi_cmnd *queue_remove_tgtluntag(Queue_t *queue, int target, int lun, in queue_remove_tgtluntag() argument
217 spin_lock_irqsave(&queue->queue_lock, flags); in queue_remove_tgtluntag()
218 list_for_each(l, &queue->head) { in queue_remove_tgtluntag()
219 QE_t *q = list_entry(l, QE_t, list); in queue_remove_tgtluntag()
220 if (q->SCpnt->device->id == target && q->SCpnt->device->lun == lun && in queue_remove_tgtluntag()
221 scsi_cmd_to_rq(q->SCpnt)->tag == tag) { in queue_remove_tgtluntag()
226 spin_unlock_irqrestore(&queue->queue_lock, flags); in queue_remove_tgtluntag()
232 * Function: queue_remove_all_target(queue, target)
233 * Purpose : remove all SCSI commands from the queue for a specified target
234 * Params : queue - queue to remove command from
235 * target - target device id
238 void queue_remove_all_target(Queue_t *queue, int target) in queue_remove_all_target() argument
243 spin_lock_irqsave(&queue->queue_lock, flags); in queue_remove_all_target()
244 list_for_each(l, &queue->head) { in queue_remove_all_target()
245 QE_t *q = list_entry(l, QE_t, list); in queue_remove_all_target()
246 if (q->SCpnt->device->id == target) in queue_remove_all_target()
249 spin_unlock_irqrestore(&queue->queue_lock, flags); in queue_remove_all_target()
253 * Function: int queue_probetgtlun (queue, target, lun)
255 * target/lun.
256 * Params : queue - queue to look in
257 * target - target we want to probe
258 * lun - lun on target
261 int queue_probetgtlun (Queue_t *queue, int target, int lun) in queue_probetgtlun() argument
267 spin_lock_irqsave(&queue->queue_lock, flags); in queue_probetgtlun()
268 list_for_each(l, &queue->head) { in queue_probetgtlun()
269 QE_t *q = list_entry(l, QE_t, list); in queue_probetgtlun()
270 if (q->SCpnt->device->id == target && q->SCpnt->device->lun == lun) { in queue_probetgtlun()
275 spin_unlock_irqrestore(&queue->queue_lock, flags); in queue_probetgtlun()
283 * Params : queue - queue to look in
284 * SCpnt - command to find
293 spin_lock_irqsave(&queue->queue_lock, flags); in queue_remove_cmd()
294 list_for_each(l, &queue->head) { in queue_remove_cmd()
295 QE_t *q = list_entry(l, QE_t, list); in queue_remove_cmd()
296 if (q->SCpnt == SCpnt) { in queue_remove_cmd()
302 spin_unlock_irqrestore(&queue->queue_lock, flags); in queue_remove_cmd()