2019-06-04 16:11:33 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* linux/drivers/acorn/scsi/queue.h: queue handling
|
|
|
|
*
|
|
|
|
* Copyright (C) 1997 Russell King
|
|
|
|
*/
|
|
|
|
#ifndef QUEUE_H
|
|
|
|
#define QUEUE_H
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
struct list_head head;
|
|
|
|
struct list_head free;
|
|
|
|
spinlock_t queue_lock;
|
|
|
|
void *alloc; /* start of allocated mem */
|
|
|
|
} Queue_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: void queue_initialise (Queue_t *queue)
|
|
|
|
* Purpose : initialise a queue
|
|
|
|
* Params : queue - queue to initialise
|
|
|
|
*/
|
|
|
|
extern int queue_initialise (Queue_t *queue);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: void queue_free (Queue_t *queue)
|
|
|
|
* Purpose : free a queue
|
|
|
|
* Params : queue - queue to free
|
|
|
|
*/
|
|
|
|
extern void queue_free (Queue_t *queue);
|
|
|
|
|
|
|
|
/*
|
2006-10-01 19:18:37 +08:00
|
|
|
* Function: struct scsi_cmnd *queue_remove (queue)
|
2005-04-17 06:20:36 +08:00
|
|
|
* Purpose : removes first SCSI command from a queue
|
|
|
|
* Params : queue - queue to remove command from
|
2006-10-01 19:18:37 +08:00
|
|
|
* Returns : struct scsi_cmnd if successful (and a reference), or NULL if no command available
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2006-10-01 19:18:37 +08:00
|
|
|
extern struct scsi_cmnd *queue_remove (Queue_t *queue);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
2006-10-01 19:18:37 +08:00
|
|
|
* Function: struct scsi_cmnd *queue_remove_exclude_ref (queue, exclude)
|
2005-04-17 06:20:36 +08:00
|
|
|
* Purpose : remove a SCSI command from a queue
|
|
|
|
* Params : queue - queue to remove command from
|
|
|
|
* exclude - array of busy LUNs
|
2006-10-01 19:18:37 +08:00
|
|
|
* Returns : struct scsi_cmnd if successful (and a reference), or NULL if no command available
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2006-10-01 19:18:37 +08:00
|
|
|
extern struct scsi_cmnd *queue_remove_exclude(Queue_t *queue,
|
|
|
|
unsigned long *exclude);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define queue_add_cmd_ordered(queue,SCpnt) \
|
|
|
|
__queue_add(queue,SCpnt,(SCpnt)->cmnd[0] == REQUEST_SENSE)
|
|
|
|
#define queue_add_cmd_tail(queue,SCpnt) \
|
|
|
|
__queue_add(queue,SCpnt,0)
|
|
|
|
/*
|
2006-10-01 19:18:37 +08:00
|
|
|
* Function: int __queue_add(Queue_t *queue, struct scsi_cmnd *SCpnt, int head)
|
2005-04-17 06:20:36 +08:00
|
|
|
* Purpose : Add a new command onto a queue
|
|
|
|
* Params : queue - destination queue
|
|
|
|
* SCpnt - command to add
|
|
|
|
* head - add command to head of queue
|
|
|
|
* Returns : 0 on error, !0 on success
|
|
|
|
*/
|
2006-10-01 19:18:37 +08:00
|
|
|
extern int __queue_add(Queue_t *queue, struct scsi_cmnd *SCpnt, int head);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
2006-10-01 19:18:37 +08:00
|
|
|
* Function: struct scsi_cmnd *queue_remove_tgtluntag (queue, target, lun, tag)
|
2005-04-17 06:20:36 +08:00
|
|
|
* Purpose : remove a SCSI command from the queue for a specified target/lun/tag
|
|
|
|
* Params : queue - queue to remove command from
|
|
|
|
* target - target that we want
|
|
|
|
* lun - lun on device
|
|
|
|
* tag - tag on device
|
2006-10-01 19:18:37 +08:00
|
|
|
* Returns : struct scsi_cmnd if successful, or NULL if no command satisfies requirements
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2006-10-01 19:18:37 +08:00
|
|
|
extern struct scsi_cmnd *queue_remove_tgtluntag(Queue_t *queue, int target,
|
|
|
|
int lun, int tag);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: queue_remove_all_target(queue, target)
|
|
|
|
* Purpose : remove all SCSI commands from the queue for a specified target
|
|
|
|
* Params : queue - queue to remove command from
|
|
|
|
* target - target device id
|
|
|
|
* Returns : nothing
|
|
|
|
*/
|
|
|
|
extern void queue_remove_all_target(Queue_t *queue, int target);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: int queue_probetgtlun (queue, target, lun)
|
|
|
|
* Purpose : check to see if we have a command in the queue for the specified
|
|
|
|
* target/lun.
|
|
|
|
* Params : queue - queue to look in
|
|
|
|
* target - target we want to probe
|
|
|
|
* lun - lun on target
|
|
|
|
* Returns : 0 if not found, != 0 if found
|
|
|
|
*/
|
|
|
|
extern int queue_probetgtlun (Queue_t *queue, int target, int lun);
|
|
|
|
|
|
|
|
/*
|
2006-10-01 19:18:37 +08:00
|
|
|
* Function: int queue_remove_cmd (Queue_t *queue, struct scsi_cmnd *SCpnt)
|
2005-04-17 06:20:36 +08:00
|
|
|
* Purpose : remove a specific command from the queues
|
|
|
|
* Params : queue - queue to look in
|
|
|
|
* SCpnt - command to find
|
|
|
|
* Returns : 0 if not found
|
|
|
|
*/
|
2006-10-01 19:18:37 +08:00
|
|
|
int queue_remove_cmd(Queue_t *queue, struct scsi_cmnd *SCpnt);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#endif /* QUEUE_H */
|